@@ -76,19 +76,19 @@ discard block |
||
76 | 76 | // $this->url = 'https://wetu.com/API/Pins/'; |
77 | 77 | // $this->url_qs = 'username=' . $this->api_username . '&password=' . $this->api_password; |
78 | 78 | //} elseif ( false !== $this->api_key ) { |
79 | - $this->url = 'https://wetu.com/API/Pins/' . $this->api_key; |
|
79 | + $this->url = 'https://wetu.com/API/Pins/'.$this->api_key; |
|
80 | 80 | $this->url_qs = 'all=include'; |
81 | 81 | //} |
82 | 82 | |
83 | - $temp_options = get_option( '_lsx-to_settings', false ); |
|
83 | + $temp_options = get_option('_lsx-to_settings', false); |
|
84 | 84 | |
85 | - if ( false !== $temp_options && isset( $temp_options[ $this->plugin_slug ] ) && ! empty( $temp_options[ $this->plugin_slug ] ) ) { |
|
86 | - $this->options = $temp_options[ $this->plugin_slug ]; |
|
85 | + if (false !== $temp_options && isset($temp_options[$this->plugin_slug]) && !empty($temp_options[$this->plugin_slug])) { |
|
86 | + $this->options = $temp_options[$this->plugin_slug]; |
|
87 | 87 | } |
88 | 88 | |
89 | - $accommodation_options = get_option( 'wetu_importer_accommodation_settings',false ); |
|
89 | + $accommodation_options = get_option('wetu_importer_accommodation_settings', false); |
|
90 | 90 | |
91 | - if ( false !== $accommodation_options ) { |
|
91 | + if (false !== $accommodation_options) { |
|
92 | 92 | $this->accommodation_options = $accommodation_options; |
93 | 93 | } |
94 | 94 | } |
@@ -99,17 +99,17 @@ discard block |
||
99 | 99 | public function display_page() { |
100 | 100 | ?> |
101 | 101 | <div class="wrap"> |
102 | - <?php $this->navigation( 'accommodation' ); ?> |
|
102 | + <?php $this->navigation('accommodation'); ?> |
|
103 | 103 | |
104 | 104 | <?php $this->update_options_form(); ?> |
105 | 105 | |
106 | 106 | <?php $this->search_form(); ?> |
107 | 107 | |
108 | 108 | <form method="get" action="" id="posts-filter"> |
109 | - <input type="hidden" name="post_type" class="post_type" value="<?php echo esc_attr( $this->tab_slug ); ?>" /> |
|
109 | + <input type="hidden" name="post_type" class="post_type" value="<?php echo esc_attr($this->tab_slug); ?>" /> |
|
110 | 110 | |
111 | - <p><input class="button button-primary add" type="button" value="<?php esc_attr_e( 'Add to List', 'wetu-importer' ); ?>" /> |
|
112 | - <input class="button button-primary clear" type="button" value="<?php esc_attr_e( 'Clear', 'wetu-importer' ); ?>" /> |
|
111 | + <p><input class="button button-primary add" type="button" value="<?php esc_attr_e('Add to List', 'wetu-importer'); ?>" /> |
|
112 | + <input class="button button-primary clear" type="button" value="<?php esc_attr_e('Clear', 'wetu-importer'); ?>" /> |
|
113 | 113 | </p> |
114 | 114 | |
115 | 115 | <table class="wp-list-table widefat fixed posts"> |
@@ -118,11 +118,11 @@ discard block |
||
118 | 118 | <tbody id="the-list"> |
119 | 119 | <tr class="post-0 type-tour status-none" id="post-0"> |
120 | 120 | <th class="check-column" scope="row"> |
121 | - <label for="cb-select-0" class="screen-reader-text"><?php esc_html_e( 'Enter a title to search for and press enter', 'wetu-importer' ); ?></label> |
|
121 | + <label for="cb-select-0" class="screen-reader-text"><?php esc_html_e('Enter a title to search for and press enter', 'wetu-importer'); ?></label> |
|
122 | 122 | </th> |
123 | 123 | <td class="post-title page-title column-title"> |
124 | 124 | <strong> |
125 | - <?php esc_html_e( 'Enter a title to search for', 'wetu-importer' ); ?> |
|
125 | + <?php esc_html_e('Enter a title to search for', 'wetu-importer'); ?> |
|
126 | 126 | </strong> |
127 | 127 | </td> |
128 | 128 | <td class="date column-date"> |
@@ -136,8 +136,8 @@ discard block |
||
136 | 136 | |
137 | 137 | </table> |
138 | 138 | |
139 | - <p><input class="button button-primary add" type="button" value="<?php esc_attr_e( 'Add to List', 'wetu-importer' ); ?>" /> |
|
140 | - <input class="button button-primary clear" type="button" value="<?php esc_attr_e( 'Clear', 'wetu-importer' ); ?>" /> |
|
139 | + <p><input class="button button-primary add" type="button" value="<?php esc_attr_e('Add to List', 'wetu-importer'); ?>" /> |
|
140 | + <input class="button button-primary clear" type="button" value="<?php esc_attr_e('Clear', 'wetu-importer'); ?>" /> |
|
141 | 141 | </p> |
142 | 142 | </form> |
143 | 143 | |
@@ -147,66 +147,66 @@ discard block |
||
147 | 147 | |
148 | 148 | <div class="row"> |
149 | 149 | <div class="settings-all" style="width:30%;display:block;float:left;"> |
150 | - <h3><?php esc_html_e( 'What content to Sync from WETU' ); ?></h3> |
|
150 | + <h3><?php esc_html_e('What content to Sync from WETU'); ?></h3> |
|
151 | 151 | <ul> |
152 | - <li><input class="content select-all" <?php $this->checked( $this->accommodation_options, 'all' ); ?> type="checkbox" name="content[]" value="all" /> <?php esc_html_e( 'Select All', 'wetu-importer' ); ?></li> |
|
153 | - <?php if ( ! isset( $this->options['disable_accommodation_descriptions'] ) ) { ?> |
|
154 | - <li><input class="content" checked="<?php $this->checked( $this->accommodation_options,'description' ); ?>" type="checkbox" name="content[]" value="description" /> <?php esc_html_e( 'Description', 'wetu-importer' ); ?></li> |
|
152 | + <li><input class="content select-all" <?php $this->checked($this->accommodation_options, 'all'); ?> type="checkbox" name="content[]" value="all" /> <?php esc_html_e('Select All', 'wetu-importer'); ?></li> |
|
153 | + <?php if (!isset($this->options['disable_accommodation_descriptions'])) { ?> |
|
154 | + <li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'description'); ?>" type="checkbox" name="content[]" value="description" /> <?php esc_html_e('Description', 'wetu-importer'); ?></li> |
|
155 | 155 | <?php } ?> |
156 | - <?php if ( ! isset( $this->options['disable_accommodation_excerpts'] ) ) { ?> |
|
157 | - <li><input class="content" checked="<?php $this->checked( $this->accommodation_options,'excerpt' ); ?>" type="checkbox" name="content[]" value="excerpt" /> <?php esc_html_e( 'Excerpt', 'wetu-importer' ); ?></li> |
|
156 | + <?php if (!isset($this->options['disable_accommodation_excerpts'])) { ?> |
|
157 | + <li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'excerpt'); ?>" type="checkbox" name="content[]" value="excerpt" /> <?php esc_html_e('Excerpt', 'wetu-importer'); ?></li> |
|
158 | 158 | <?php } ?> |
159 | 159 | |
160 | - <?php if ( ! isset( $this->accommodation_settings['disable_single'] ) ) { ?> |
|
161 | - <li><input class="content" checked="<?php $this->checked( $this->accommodation_options,'gallery' ); ?>" type="checkbox" name="content[]" value="gallery" /> <?php esc_html_e( 'Main Gallery', 'wetu-importer' ); ?></li> |
|
160 | + <?php if (!isset($this->accommodation_settings['disable_single'])) { ?> |
|
161 | + <li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'gallery'); ?>" type="checkbox" name="content[]" value="gallery" /> <?php esc_html_e('Main Gallery', 'wetu-importer'); ?></li> |
|
162 | 162 | <?php } ?> |
163 | - <li><input class="content" checked="<?php $this->checked( $this->accommodation_options,'category' ); ?>" type="checkbox" name="content[]" value="category" /> <?php esc_html_e( 'Category', 'wetu-importer' ); ?></li> |
|
164 | - <?php if ( class_exists( 'LSX_TO_Maps' ) && ! isset( $this->accommodation_settings['disable_single'] ) ) { ?> |
|
165 | - <li><input class="content" checked="<?php $this->checked( $this->accommodation_options,'location' ); ?>" type="checkbox" name="content[]" value="location" /> <?php esc_html_e( 'Location', 'wetu-importer' ); ?></li> |
|
163 | + <li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'category'); ?>" type="checkbox" name="content[]" value="category" /> <?php esc_html_e('Category', 'wetu-importer'); ?></li> |
|
164 | + <?php if (class_exists('LSX_TO_Maps') && !isset($this->accommodation_settings['disable_single'])) { ?> |
|
165 | + <li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'location'); ?>" type="checkbox" name="content[]" value="location" /> <?php esc_html_e('Location', 'wetu-importer'); ?></li> |
|
166 | 166 | <?php } ?> |
167 | - <li><input class="content" checked="<?php $this->checked( $this->accommodation_options,'destination' ); ?>" type="checkbox" name="content[]" value="destination" /> <?php esc_html_e( 'Connect Destinations', 'wetu-importer' ); ?></li> |
|
168 | - <li><input class="content" checked="<?php $this->checked( $this->accommodation_options,'rating' ); ?>" type="checkbox" name="content[]" value="rating" /> <?php esc_html_e( 'Rating', 'wetu-importer' ); ?></li> |
|
169 | - <li><input class="content" checked="<?php $this->checked( $this->accommodation_options,'rooms' ); ?>" type="checkbox" name="content[]" value="rooms" /> <?php esc_html_e( 'Rooms', 'wetu-importer' ); ?></li> |
|
170 | - |
|
171 | - <?php if ( ! isset( $this->accommodation_settings['disable_single'] ) ) { ?> |
|
172 | - <li><input class="content" checked="<?php $this->checked( $this->accommodation_options,'checkin' ); ?>" type="checkbox" name="content[]" value="checkin" /> <?php esc_html_e( 'Check In / Check Out', 'wetu-importer' ); ?></li> |
|
173 | - <li><input class="content" checked="<?php $this->checked( $this->accommodation_options,'facilities' ); ?>" type="checkbox" name="content[]" value="facilities" /> <?php esc_html_e( 'Facilities', 'wetu-importer' ); ?></li> |
|
174 | - <li><input class="content" checked="<?php $this->checked( $this->accommodation_options,'friendly' ); ?>" type="checkbox" name="content[]" value="friendly" /> <?php esc_html_e( 'Friendly', 'wetu-importer' ); ?></li> |
|
167 | + <li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'destination'); ?>" type="checkbox" name="content[]" value="destination" /> <?php esc_html_e('Connect Destinations', 'wetu-importer'); ?></li> |
|
168 | + <li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'rating'); ?>" type="checkbox" name="content[]" value="rating" /> <?php esc_html_e('Rating', 'wetu-importer'); ?></li> |
|
169 | + <li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'rooms'); ?>" type="checkbox" name="content[]" value="rooms" /> <?php esc_html_e('Rooms', 'wetu-importer'); ?></li> |
|
170 | + |
|
171 | + <?php if (!isset($this->accommodation_settings['disable_single'])) { ?> |
|
172 | + <li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'checkin'); ?>" type="checkbox" name="content[]" value="checkin" /> <?php esc_html_e('Check In / Check Out', 'wetu-importer'); ?></li> |
|
173 | + <li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'facilities'); ?>" type="checkbox" name="content[]" value="facilities" /> <?php esc_html_e('Facilities', 'wetu-importer'); ?></li> |
|
174 | + <li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'friendly'); ?>" type="checkbox" name="content[]" value="friendly" /> <?php esc_html_e('Friendly', 'wetu-importer'); ?></li> |
|
175 | 175 | <?php } ?> |
176 | 176 | |
177 | - <li><input class="content" checked="<?php $this->checked( $this->accommodation_options,'special_interests' ); ?>" type="checkbox" name="content[]" value="special_interests" /> <?php esc_html_e( 'Special Interests', 'wetu-importer' ); ?></li> |
|
178 | - <li><input class="content" checked="<?php $this->checked( $this->accommodation_options,'spoken_languages' ); ?>" type="checkbox" name="content[]" value="spoken_languages" /> <?php esc_html_e( 'Spoken Languages', 'wetu-importer' ); ?></li> |
|
177 | + <li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'special_interests'); ?>" type="checkbox" name="content[]" value="special_interests" /> <?php esc_html_e('Special Interests', 'wetu-importer'); ?></li> |
|
178 | + <li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'spoken_languages'); ?>" type="checkbox" name="content[]" value="spoken_languages" /> <?php esc_html_e('Spoken Languages', 'wetu-importer'); ?></li> |
|
179 | 179 | |
180 | - <?php if ( class_exists( 'LSX_TO_Videos' ) && ! isset( $this->accommodation_settings['disable_single'] ) ) { ?> |
|
181 | - <li><input class="content" checked="<?php $this->checked( $this->accommodation_options,'videos' ); ?>" type="checkbox" name="content[]" value="videos" /> <?php esc_html_e( 'Videos', 'wetu-importer' ); ?></li> |
|
180 | + <?php if (class_exists('LSX_TO_Videos') && !isset($this->accommodation_settings['disable_single'])) { ?> |
|
181 | + <li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'videos'); ?>" type="checkbox" name="content[]" value="videos" /> <?php esc_html_e('Videos', 'wetu-importer'); ?></li> |
|
182 | 182 | <?php } ?> |
183 | 183 | </ul> |
184 | - <h4><?php esc_html_e( 'Additional Content' ); ?></h4> |
|
184 | + <h4><?php esc_html_e('Additional Content'); ?></h4> |
|
185 | 185 | <ul> |
186 | - <li><input class="content" checked="<?php $this->checked( $this->accommodation_options,'featured_image' ); ?>" type="checkbox" name="content[]" value="featured_image" /> <?php esc_html_e( 'Set Featured Image', 'wetu-importer' ); ?></li> |
|
187 | - <?php if ( class_exists( 'LSX_Banners' ) && ! isset( $this->accommodation_settings['disable_single'] ) ) { ?> |
|
188 | - <li><input class="content" checked="<?php $this->checked( $this->accommodation_options,'banner_image' ); ?>" type="checkbox" name="content[]" value="banner_image" /> <?php esc_html_e( 'Set Banner Image', 'wetu-importer' ); ?></li> |
|
186 | + <li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'featured_image'); ?>" type="checkbox" name="content[]" value="featured_image" /> <?php esc_html_e('Set Featured Image', 'wetu-importer'); ?></li> |
|
187 | + <?php if (class_exists('LSX_Banners') && !isset($this->accommodation_settings['disable_single'])) { ?> |
|
188 | + <li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'banner_image'); ?>" type="checkbox" name="content[]" value="banner_image" /> <?php esc_html_e('Set Banner Image', 'wetu-importer'); ?></li> |
|
189 | 189 | <?php } ?> |
190 | 190 | </ul> |
191 | 191 | </div> |
192 | 192 | <div style="width:30%;display:block;float:left;"> |
193 | - <h3><?php esc_html_e( 'Assign a Team Member' ); ?></h3> |
|
194 | - <?php $this->team_member_checkboxes( $this->accommodation_options ); ?> |
|
193 | + <h3><?php esc_html_e('Assign a Team Member'); ?></h3> |
|
194 | + <?php $this->team_member_checkboxes($this->accommodation_options); ?> |
|
195 | 195 | </div> |
196 | 196 | |
197 | 197 | <div style="width:30%;display:block;float:left;"> |
198 | - <h3><?php esc_html_e( 'Assign a Safari Brand' ); ?></h3> |
|
198 | + <h3><?php esc_html_e('Assign a Safari Brand'); ?></h3> |
|
199 | 199 | <?php |
200 | 200 | // @codingStandardsIgnoreLine |
201 | - echo $this->taxonomy_checkboxes( 'accommodation-brand', $this->accommodation_options ); |
|
201 | + echo $this->taxonomy_checkboxes('accommodation-brand', $this->accommodation_options); |
|
202 | 202 | ?> |
203 | 203 | </div> |
204 | 204 | |
205 | 205 | <br clear="both" /> |
206 | 206 | </div> |
207 | 207 | |
208 | - <h3><?php esc_html_e( 'Your List' ); ?></h3> |
|
209 | - <p><input class="button button-primary" type="submit" value="<?php esc_attr_e( 'Sync', 'wetu-importer' ); ?>" /></p> |
|
208 | + <h3><?php esc_html_e('Your List'); ?></h3> |
|
209 | + <p><input class="button button-primary" type="submit" value="<?php esc_attr_e('Sync', 'wetu-importer'); ?>" /></p> |
|
210 | 210 | <table class="wp-list-table widefat fixed posts"> |
211 | 211 | <?php $this->table_header(); ?> |
212 | 212 | |
@@ -218,12 +218,12 @@ discard block |
||
218 | 218 | |
219 | 219 | </table> |
220 | 220 | |
221 | - <p><input class="button button-primary" type="submit" value="<?php esc_attr_e( 'Sync', 'wetu-importer' ); ?>" /></p> |
|
221 | + <p><input class="button button-primary" type="submit" value="<?php esc_attr_e('Sync', 'wetu-importer'); ?>" /></p> |
|
222 | 222 | </form> |
223 | 223 | </div> |
224 | 224 | |
225 | 225 | <div style="display:none;" class="completed-list-wrapper"> |
226 | - <h3><?php esc_html_e( 'Completed' ); ?> - <small><?php esc_html_e( 'Import your', 'wetu-importer' ); ?> <a href="<?php echo esc_url( admin_url( 'admin.php' ) ); ?>?page=<?php echo esc_attr( $this->plugin_slug ); ?>&tab=destination"><?php esc_html_e( 'destinations' ); ?></a> <?php esc_html_e( 'next', 'wetu-importer' ); ?></small></h3> |
|
226 | + <h3><?php esc_html_e('Completed'); ?> - <small><?php esc_html_e('Import your', 'wetu-importer'); ?> <a href="<?php echo esc_url(admin_url('admin.php')); ?>?page=<?php echo esc_attr($this->plugin_slug); ?>&tab=destination"><?php esc_html_e('destinations'); ?></a> <?php esc_html_e('next', 'wetu-importer'); ?></small></h3> |
|
227 | 227 | <ul> |
228 | 228 | </ul> |
229 | 229 | </div> |
@@ -235,9 +235,9 @@ discard block |
||
235 | 235 | * search_form |
236 | 236 | */ |
237 | 237 | public function update_options_form() { |
238 | - echo '<div style="display:none;" class="wetu-status"><h3>' . esc_html__( 'Wetu Status', 'wetu-importer' ) . '</h3>'; |
|
238 | + echo '<div style="display:none;" class="wetu-status"><h3>'.esc_html__('Wetu Status', 'wetu-importer').'</h3>'; |
|
239 | 239 | |
240 | - $accommodation = get_transient( 'lsx_ti_accommodation' ); |
|
240 | + $accommodation = get_transient('lsx_ti_accommodation'); |
|
241 | 241 | |
242 | 242 | //if ( '' === $accommodation || false === $accommodation || isset( $_GET['refresh_accommodation'] ) ) { |
243 | 243 | //$this->update_options(); |
@@ -250,14 +250,14 @@ discard block |
||
250 | 250 | * Save the list of Accommodation into an option |
251 | 251 | */ |
252 | 252 | public function update_options() { |
253 | - $data = file_get_contents( $this->url . '/List?' . $this->url_qs ); |
|
253 | + $data = file_get_contents($this->url.'/List?'.$this->url_qs); |
|
254 | 254 | |
255 | - $accommodation = json_decode( $data, true ); |
|
255 | + $accommodation = json_decode($data, true); |
|
256 | 256 | |
257 | - if ( isset( $accommodation['error'] ) ) { |
|
257 | + if (isset($accommodation['error'])) { |
|
258 | 258 | return $accommodation['error']; |
259 | - } elseif ( isset( $accommodation ) && ! empty( $accommodation ) ) { |
|
260 | - set_transient( 'lsx_ti_accommodation',$accommodation,60 * 60 * 2 ); |
|
259 | + } elseif (isset($accommodation) && !empty($accommodation)) { |
|
260 | + set_transient('lsx_ti_accommodation', $accommodation, 60 * 60 * 2); |
|
261 | 261 | return true; |
262 | 262 | } |
263 | 263 | } |
@@ -269,135 +269,135 @@ discard block |
||
269 | 269 | $return = false; |
270 | 270 | |
271 | 271 | // @codingStandardsIgnoreLine |
272 | - if ( isset( $_POST['action'] ) && $_POST['action'] === 'lsx_tour_importer' && isset( $_POST['type'] ) && $_POST['type'] === 'accommodation' ) { |
|
272 | + if (isset($_POST['action']) && $_POST['action'] === 'lsx_tour_importer' && isset($_POST['type']) && $_POST['type'] === 'accommodation') { |
|
273 | 273 | |
274 | 274 | $searched_items = false; |
275 | 275 | |
276 | 276 | // @codingStandardsIgnoreLine |
277 | - if ( isset( $_POST['keyword'] ) ) { |
|
277 | + if (isset($_POST['keyword'])) { |
|
278 | 278 | // @codingStandardsIgnoreLine |
279 | 279 | $keyphrases = $_POST['keyword']; |
280 | - } else { |
|
281 | - $keyphrases = array( 0 ); |
|
280 | + }else { |
|
281 | + $keyphrases = array(0); |
|
282 | 282 | } |
283 | 283 | |
284 | - if ( ! is_array( $keyphrases ) ) { |
|
285 | - $keyphrases = array( $keyphrases ); |
|
284 | + if (!is_array($keyphrases)) { |
|
285 | + $keyphrases = array($keyphrases); |
|
286 | 286 | } |
287 | - foreach ( $keyphrases as &$keyword ) { |
|
288 | - $keyword = ltrim( rtrim( $keyword ) ); |
|
287 | + foreach ($keyphrases as &$keyword) { |
|
288 | + $keyword = ltrim(rtrim($keyword)); |
|
289 | 289 | } |
290 | 290 | |
291 | 291 | $post_status = false; |
292 | 292 | |
293 | - if ( in_array( 'publish',$keyphrases ) ) { |
|
293 | + if (in_array('publish', $keyphrases)) { |
|
294 | 294 | $post_status = 'publish'; |
295 | 295 | } |
296 | - if ( in_array( 'pending',$keyphrases ) ) { |
|
296 | + if (in_array('pending', $keyphrases)) { |
|
297 | 297 | $post_status = 'pending'; |
298 | 298 | } |
299 | - if ( in_array( 'draft',$keyphrases ) ) { |
|
299 | + if (in_array('draft', $keyphrases)) { |
|
300 | 300 | $post_status = 'draft'; |
301 | 301 | } |
302 | - if ( in_array( 'import',$keyphrases ) ) { |
|
302 | + if (in_array('import', $keyphrases)) { |
|
303 | 303 | $post_status = 'import'; |
304 | 304 | } |
305 | 305 | |
306 | 306 | // If there is a post status use it. |
307 | - if ( false !== $post_status ) { |
|
307 | + if (false !== $post_status) { |
|
308 | 308 | |
309 | 309 | $accommodation = array(); |
310 | 310 | $current_accommodation = $this->find_current_accommodation(); |
311 | - if ( ! empty( $current_accommodation ) ) { |
|
312 | - foreach ( $current_accommodation as $cs_key => $ccs_id ) { |
|
313 | - $accommodation[] = $this->prepare_row_attributes( $cs_key, $ccs_id->post_id ); |
|
311 | + if (!empty($current_accommodation)) { |
|
312 | + foreach ($current_accommodation as $cs_key => $ccs_id) { |
|
313 | + $accommodation[] = $this->prepare_row_attributes($cs_key, $ccs_id->post_id); |
|
314 | 314 | } |
315 | 315 | } |
316 | 316 | |
317 | 317 | // Run through each accommodation and use it. |
318 | - if ( ! empty( $accommodation ) ) { |
|
319 | - foreach ( $accommodation as $row_key => $row ) { |
|
320 | - if ( 'import' === $post_status ) { |
|
318 | + if (!empty($accommodation)) { |
|
319 | + foreach ($accommodation as $row_key => $row) { |
|
320 | + if ('import' === $post_status) { |
|
321 | 321 | |
322 | - if ( is_array( $this->queued_imports ) && in_array( $row['post_id'],$this->queued_imports ) ) { |
|
323 | - $searched_items[ sanitize_title( $row['name'] ) . '-' . $row['id'] ] = $this->format_row( $row ); |
|
324 | - } else { |
|
322 | + if (is_array($this->queued_imports) && in_array($row['post_id'], $this->queued_imports)) { |
|
323 | + $searched_items[sanitize_title($row['name']).'-'.$row['id']] = $this->format_row($row); |
|
324 | + }else { |
|
325 | 325 | continue; |
326 | 326 | } |
327 | - } else { |
|
328 | - if ( 0 === $row['post_id'] ) { |
|
327 | + }else { |
|
328 | + if (0 === $row['post_id']) { |
|
329 | 329 | continue; |
330 | - } else { |
|
331 | - $current_status = get_post_status( $row['post_id'] ); |
|
330 | + }else { |
|
331 | + $current_status = get_post_status($row['post_id']); |
|
332 | 332 | |
333 | - if ( $current_status !== $post_status ) { |
|
333 | + if ($current_status !== $post_status) { |
|
334 | 334 | continue; |
335 | 335 | } |
336 | 336 | } |
337 | - $searched_items[ sanitize_title( $row['name'] ) . '-' . $row['id'] ] = $this->format_row( $row ); |
|
337 | + $searched_items[sanitize_title($row['name']).'-'.$row['id']] = $this->format_row($row); |
|
338 | 338 | } |
339 | 339 | } |
340 | 340 | } |
341 | 341 | |
342 | - } else { |
|
342 | + }else { |
|
343 | 343 | |
344 | - $key_string_search = implode( '+', $keyphrases ); |
|
345 | - $search_data = file_get_contents( $this->url . '/Search/' . $key_string_search ); |
|
346 | - $search_data = json_decode( $search_data, true ); |
|
344 | + $key_string_search = implode('+', $keyphrases); |
|
345 | + $search_data = file_get_contents($this->url.'/Search/'.$key_string_search); |
|
346 | + $search_data = json_decode($search_data, true); |
|
347 | 347 | |
348 | - if ( ! isset( $search_data['error'] ) ) { |
|
349 | - foreach ( $search_data as $sdata ) { |
|
348 | + if (!isset($search_data['error'])) { |
|
349 | + foreach ($search_data as $sdata) { |
|
350 | 350 | |
351 | - if ( 'Destination' === trim( $sdata['type'] ) || |
|
352 | - 'Activity' === trim( $sdata['type'] ) || |
|
353 | - 'Restaurant' === trim( $sdata['type'] ) || |
|
354 | - 'None' === trim( $sdata['type'] ) || |
|
355 | - 'Site / Attraction' === trim( $sdata['type'] ) || |
|
356 | - '' === trim( $sdata['type'] ) |
|
351 | + if ('Destination' === trim($sdata['type']) || |
|
352 | + 'Activity' === trim($sdata['type']) || |
|
353 | + 'Restaurant' === trim($sdata['type']) || |
|
354 | + 'None' === trim($sdata['type']) || |
|
355 | + 'Site / Attraction' === trim($sdata['type']) || |
|
356 | + '' === trim($sdata['type']) |
|
357 | 357 | ) { |
358 | 358 | continue; |
359 | 359 | } |
360 | 360 | |
361 | - $temp_id = $this->get_post_id_by_key_value( $sdata['id'] ); |
|
362 | - if ( false === $temp_id ) { |
|
361 | + $temp_id = $this->get_post_id_by_key_value($sdata['id']); |
|
362 | + if (false === $temp_id) { |
|
363 | 363 | $sdata['post_id'] = 0; |
364 | - } else { |
|
364 | + }else { |
|
365 | 365 | $sdata['post_id'] = $temp_id; |
366 | 366 | } |
367 | - $searched_items[ sanitize_title( $sdata['name'] ) . '-' . $sdata['id'] ] = $this->format_row( $sdata ); |
|
367 | + $searched_items[sanitize_title($sdata['name']).'-'.$sdata['id']] = $this->format_row($sdata); |
|
368 | 368 | } |
369 | 369 | } |
370 | 370 | } |
371 | 371 | |
372 | - if ( false !== $searched_items ) { |
|
373 | - ksort( $searched_items ); |
|
374 | - $return = implode( $searched_items ); |
|
372 | + if (false !== $searched_items) { |
|
373 | + ksort($searched_items); |
|
374 | + $return = implode($searched_items); |
|
375 | 375 | } |
376 | 376 | |
377 | - print_r( $return ); |
|
377 | + print_r($return); |
|
378 | 378 | } |
379 | 379 | |
380 | 380 | die(); |
381 | 381 | } |
382 | 382 | |
383 | - private function get_post_id_by_key_value( $wetu_id = false ) { |
|
383 | + private function get_post_id_by_key_value($wetu_id = false) { |
|
384 | 384 | global $wpdb; |
385 | 385 | $id = false; |
386 | - if ( false !== $wetu_id && '' !== $wetu_id ) { |
|
386 | + if (false !== $wetu_id && '' !== $wetu_id) { |
|
387 | 387 | $result = $wpdb->get_var("SELECT post_id FROM `vtbY3n_postmeta` WHERE `meta_key` = 'lsx_wetu_id' AND `meta_value` = '{$wetu_id}'"); |
388 | - if ( false !== $result && ! empty( $result ) ) { |
|
388 | + if (false !== $result && !empty($result)) { |
|
389 | 389 | $id = $result; |
390 | 390 | } |
391 | 391 | } |
392 | 392 | return $id; |
393 | 393 | } |
394 | 394 | |
395 | - public function prepare_row_attributes( $cs_key, $ccs_id ) { |
|
395 | + public function prepare_row_attributes($cs_key, $ccs_id) { |
|
396 | 396 | return $row_item = array( |
397 | 397 | 'id' => $cs_key, |
398 | 398 | 'type' => 'Accommodation', |
399 | - 'name' => get_the_title( $ccs_id ), |
|
400 | - 'last_modified' => date('Y-m-d', strtotime( 'now' ) ), |
|
399 | + 'name' => get_the_title($ccs_id), |
|
400 | + 'last_modified' => date('Y-m-d', strtotime('now')), |
|
401 | 401 | 'post_id' => $ccs_id, |
402 | 402 | ); |
403 | 403 | } |
@@ -405,28 +405,28 @@ discard block |
||
405 | 405 | /** |
406 | 406 | * Formats the row for output on the screen. |
407 | 407 | */ |
408 | - public function format_row( $row = false ) { |
|
409 | - if ( false !== $row ) { |
|
408 | + public function format_row($row = false) { |
|
409 | + if (false !== $row) { |
|
410 | 410 | |
411 | 411 | $status = 'import'; |
412 | - if ( 0 !== $row['post_id'] ) { |
|
413 | - $status = '<a href="' . admin_url( '/post.php?post=' . $row['post_id'] . '&action=edit' ) . '" target="_blank">' . get_post_status( $row['post_id'] ) . '</a>'; |
|
412 | + if (0 !== $row['post_id']) { |
|
413 | + $status = '<a href="'.admin_url('/post.php?post='.$row['post_id'].'&action=edit').'" target="_blank">'.get_post_status($row['post_id']).'</a>'; |
|
414 | 414 | } |
415 | 415 | |
416 | 416 | $row_html = ' |
417 | - <tr class="post-' . $row['post_id'] . ' type-tour" id="post-' . $row['post_id'] . '"> |
|
417 | + <tr class="post-' . $row['post_id'].' type-tour" id="post-'.$row['post_id'].'"> |
|
418 | 418 | <th class="check-column" scope="row"> |
419 | - <label for="cb-select-' . $row['id'] . '" class="screen-reader-text">' . $row['name'] . '</label> |
|
420 | - <input type="checkbox" data-identifier="' . $row['id'] . '" value="' . $row['post_id'] . '" name="post[]" id="cb-select-' . $row['id'] . '"> |
|
419 | + <label for="cb-select-' . $row['id'].'" class="screen-reader-text">'.$row['name'].'</label> |
|
420 | + <input type="checkbox" data-identifier="' . $row['id'].'" value="'.$row['post_id'].'" name="post[]" id="cb-select-'.$row['id'].'"> |
|
421 | 421 | </th> |
422 | 422 | <td class="post-title page-title column-title"> |
423 | - <strong>' . $row['name'] . '</strong> - ' . $status . ' |
|
423 | + <strong>' . $row['name'].'</strong> - '.$status.' |
|
424 | 424 | </td> |
425 | 425 | <td class="date column-date"> |
426 | - <abbr title="' . date( 'Y/m/d',strtotime( $row['last_modified'] ) ) . '">' . date( 'Y/m/d',strtotime( $row['last_modified'] ) ) . '</abbr><br>Last Modified |
|
426 | + <abbr title="' . date('Y/m/d', strtotime($row['last_modified'])).'">'.date('Y/m/d', strtotime($row['last_modified'])).'</abbr><br>Last Modified |
|
427 | 427 | </td> |
428 | 428 | <td class="ssid column-ssid"> |
429 | - ' . $row['id'] . ' |
|
429 | + ' . $row['id'].' |
|
430 | 430 | </td> |
431 | 431 | </tr>'; |
432 | 432 | return $row_html; |
@@ -436,14 +436,14 @@ discard block |
||
436 | 436 | /** |
437 | 437 | * Saves the queue to the option. |
438 | 438 | */ |
439 | - public function remove_from_queue( $id ) { |
|
440 | - if ( ! empty( $this->queued_imports ) ) { |
|
439 | + public function remove_from_queue($id) { |
|
440 | + if (!empty($this->queued_imports)) { |
|
441 | 441 | // @codingStandardsIgnoreLine |
442 | - if ( ( $key = array_search( $id, $this->queued_imports ) ) !== false ) { |
|
443 | - unset( $this->queued_imports[ $key ] ); |
|
442 | + if (($key = array_search($id, $this->queued_imports)) !== false) { |
|
443 | + unset($this->queued_imports[$key]); |
|
444 | 444 | |
445 | - delete_option( 'wetu_importer_que' ); |
|
446 | - update_option( 'wetu_importer_que',$this->queued_imports ); |
|
445 | + delete_option('wetu_importer_que'); |
|
446 | + update_option('wetu_importer_que', $this->queued_imports); |
|
447 | 447 | } |
448 | 448 | } |
449 | 449 | } |
@@ -455,59 +455,59 @@ discard block |
||
455 | 455 | $return = false; |
456 | 456 | |
457 | 457 | // @codingStandardsIgnoreLine |
458 | - if ( isset( $_POST['action'] ) && $_POST['action'] === 'lsx_import_items' && isset( $_POST['type'] ) && $_POST['type'] === 'accommodation' && isset( $_POST['wetu_id'] ) ) { |
|
458 | + if (isset($_POST['action']) && $_POST['action'] === 'lsx_import_items' && isset($_POST['type']) && $_POST['type'] === 'accommodation' && isset($_POST['wetu_id'])) { |
|
459 | 459 | // @codingStandardsIgnoreLine |
460 | 460 | $wetu_id = $_POST['wetu_id']; |
461 | 461 | |
462 | 462 | // @codingStandardsIgnoreLine |
463 | - if ( isset( $_POST['post_id'] ) ) { |
|
463 | + if (isset($_POST['post_id'])) { |
|
464 | 464 | // @codingStandardsIgnoreLine |
465 | 465 | $post_id = $_POST['post_id']; |
466 | - } else { |
|
466 | + }else { |
|
467 | 467 | $post_id = 0; |
468 | 468 | } |
469 | 469 | |
470 | 470 | // @codingStandardsIgnoreLine |
471 | - if ( isset( $_POST['team_members'] ) ) { |
|
471 | + if (isset($_POST['team_members'])) { |
|
472 | 472 | // @codingStandardsIgnoreLine |
473 | 473 | $team_members = $_POST['team_members']; |
474 | - } else { |
|
474 | + }else { |
|
475 | 475 | $team_members = false; |
476 | 476 | } |
477 | 477 | |
478 | 478 | // @codingStandardsIgnoreLine |
479 | - if ( isset( $_POST['safari_brands'] ) ) { |
|
479 | + if (isset($_POST['safari_brands'])) { |
|
480 | 480 | // @codingStandardsIgnoreLine |
481 | 481 | $safari_brands = $_POST['safari_brands']; |
482 | - } else { |
|
482 | + }else { |
|
483 | 483 | $safari_brands = false; |
484 | 484 | } |
485 | 485 | |
486 | - delete_option( 'wetu_importer_accommodation_settings' ); |
|
486 | + delete_option('wetu_importer_accommodation_settings'); |
|
487 | 487 | |
488 | 488 | // @codingStandardsIgnoreLine |
489 | - if ( isset( $_POST['content'] ) && is_array( $_POST['content'] ) && ! empty( $_POST['content'] ) ) { |
|
489 | + if (isset($_POST['content']) && is_array($_POST['content']) && !empty($_POST['content'])) { |
|
490 | 490 | // @codingStandardsIgnoreLine |
491 | 491 | $content = $_POST['content']; |
492 | - add_option( 'wetu_importer_accommodation_settings',$content ); |
|
493 | - } else { |
|
492 | + add_option('wetu_importer_accommodation_settings', $content); |
|
493 | + }else { |
|
494 | 494 | $content = false; |
495 | 495 | } |
496 | 496 | |
497 | - $jdata = file_get_contents( $this->url . '/Get?' . $this->url_qs . '&ids=' . $wetu_id ); |
|
497 | + $jdata = file_get_contents($this->url.'/Get?'.$this->url_qs.'&ids='.$wetu_id); |
|
498 | 498 | |
499 | - if ( $jdata ) { |
|
500 | - $adata = json_decode( $jdata,true ); |
|
501 | - if ( ! empty( $adata ) && ! isset( $adata['error'] ) ) { |
|
502 | - $return = $this->import_row( $adata,$wetu_id,$post_id,$team_members,$content,$safari_brands ); |
|
503 | - $this->format_completed_row( $return ); |
|
504 | - $this->remove_from_queue( $return ); |
|
499 | + if ($jdata) { |
|
500 | + $adata = json_decode($jdata, true); |
|
501 | + if (!empty($adata) && !isset($adata['error'])) { |
|
502 | + $return = $this->import_row($adata, $wetu_id, $post_id, $team_members, $content, $safari_brands); |
|
503 | + $this->format_completed_row($return); |
|
504 | + $this->remove_from_queue($return); |
|
505 | 505 | $this->cleanup_posts(); |
506 | - } else { |
|
507 | - if ( isset( $adata['error'] ) ) { |
|
508 | - $this->format_error( $adata['error'] ); |
|
509 | - } else { |
|
510 | - $this->format_error( esc_html__( 'There was a problem importing your accommodation, please try refreshing the page.', 'wetu-importer' ) ); |
|
506 | + }else { |
|
507 | + if (isset($adata['error'])) { |
|
508 | + $this->format_error($adata['error']); |
|
509 | + }else { |
|
510 | + $this->format_error(esc_html__('There was a problem importing your accommodation, please try refreshing the page.', 'wetu-importer')); |
|
511 | 511 | } |
512 | 512 | } |
513 | 513 | } |
@@ -517,7 +517,7 @@ discard block |
||
517 | 517 | /** |
518 | 518 | * Connect to wetu |
519 | 519 | */ |
520 | - public function import_row( $data, $wetu_id, $id = 0, $team_members = false, $importable_content = false, $safari_brands = false ) { |
|
520 | + public function import_row($data, $wetu_id, $id = 0, $team_members = false, $importable_content = false, $safari_brands = false) { |
|
521 | 521 | $post_name = ''; |
522 | 522 | $data_post_content = ''; |
523 | 523 | $data_post_excerpt = ''; |
@@ -529,139 +529,139 @@ discard block |
||
529 | 529 | $content_used_general_description = false; |
530 | 530 | |
531 | 531 | //Set the post_content |
532 | - if ( false !== $importable_content && in_array( 'description',$importable_content ) ) { |
|
533 | - if ( isset( $data[0]['content']['extended_description'] ) ) { |
|
532 | + if (false !== $importable_content && in_array('description', $importable_content)) { |
|
533 | + if (isset($data[0]['content']['extended_description'])) { |
|
534 | 534 | $data_post_content = $data[0]['content']['extended_description']; |
535 | - } elseif ( isset( $data[0]['content']['general_description'] ) ) { |
|
535 | + } elseif (isset($data[0]['content']['general_description'])) { |
|
536 | 536 | $data_post_content = $data[0]['content']['general_description']; |
537 | 537 | $content_used_general_description = true; |
538 | - } elseif ( isset( $data[0]['content']['teaser_description'] ) ) { |
|
538 | + } elseif (isset($data[0]['content']['teaser_description'])) { |
|
539 | 539 | $data_post_content = $data[0]['content']['teaser_description']; |
540 | 540 | } |
541 | 541 | |
542 | - $post['post_content'] = wp_strip_all_tags( $data_post_content ); |
|
542 | + $post['post_content'] = wp_strip_all_tags($data_post_content); |
|
543 | 543 | } |
544 | 544 | |
545 | 545 | //set the post_excerpt |
546 | - if ( false !== $importable_content && in_array( 'excerpt',$importable_content ) ) { |
|
547 | - if ( isset( $data[0]['content']['teaser_description'] ) ) { |
|
546 | + if (false !== $importable_content && in_array('excerpt', $importable_content)) { |
|
547 | + if (isset($data[0]['content']['teaser_description'])) { |
|
548 | 548 | $data_post_excerpt = $data[0]['content']['teaser_description']; |
549 | - } elseif ( isset( $data[0]['content']['general_description'] ) && false === $content_used_general_description ) { |
|
549 | + } elseif (isset($data[0]['content']['general_description']) && false === $content_used_general_description) { |
|
550 | 550 | $data_post_excerpt = $data[0]['content']['general_description']; |
551 | 551 | } |
552 | 552 | |
553 | 553 | $post['post_excerpt'] = $data_post_excerpt; |
554 | 554 | } |
555 | 555 | |
556 | - if ( false !== $id && '0' !== $id ) { |
|
556 | + if (false !== $id && '0' !== $id) { |
|
557 | 557 | $post['ID'] = $id; |
558 | 558 | |
559 | - if ( isset( $data[0]['name'] ) ) { |
|
559 | + if (isset($data[0]['name'])) { |
|
560 | 560 | $post['post_title'] = $data[0]['name']; |
561 | 561 | $post['post_status'] = 'publish'; |
562 | - $post['post_name'] = wp_unique_post_slug( sanitize_title( $data[0]['name'] ),$id, 'draft', 'accommodation', 0 ); |
|
562 | + $post['post_name'] = wp_unique_post_slug(sanitize_title($data[0]['name']), $id, 'draft', 'accommodation', 0); |
|
563 | 563 | } |
564 | 564 | |
565 | - $id = wp_update_post( $post ); |
|
566 | - $prev_date = get_post_meta( $id,'lsx_wetu_modified_date', true ); |
|
567 | - update_post_meta( $id, 'lsx_wetu_modified_date', strtotime( $data[0]['last_modified'] ), $prev_date ); |
|
568 | - } else { |
|
565 | + $id = wp_update_post($post); |
|
566 | + $prev_date = get_post_meta($id, 'lsx_wetu_modified_date', true); |
|
567 | + update_post_meta($id, 'lsx_wetu_modified_date', strtotime($data[0]['last_modified']), $prev_date); |
|
568 | + }else { |
|
569 | 569 | //Set the name |
570 | - if ( isset( $data[0]['name'] ) ) { |
|
571 | - $post_name = wp_unique_post_slug( sanitize_title( $data[0]['name'] ),$id, 'draft', 'accommodation', 0 ); |
|
570 | + if (isset($data[0]['name'])) { |
|
571 | + $post_name = wp_unique_post_slug(sanitize_title($data[0]['name']), $id, 'draft', 'accommodation', 0); |
|
572 | 572 | } |
573 | 573 | |
574 | 574 | $post['post_name'] = $post_name; |
575 | 575 | $post['post_title'] = $data[0]['name']; |
576 | 576 | $post['post_status'] = 'publish'; |
577 | - $id = wp_insert_post( $post ); |
|
577 | + $id = wp_insert_post($post); |
|
578 | 578 | |
579 | 579 | //Save the WETU ID and the Last date it was modified. |
580 | - if ( false !== $id ) { |
|
581 | - add_post_meta( $id,'lsx_wetu_id',$wetu_id ); |
|
582 | - add_post_meta( $id,'lsx_wetu_modified_date',strtotime( $data[0]['last_modified'] ) ); |
|
580 | + if (false !== $id) { |
|
581 | + add_post_meta($id, 'lsx_wetu_id', $wetu_id); |
|
582 | + add_post_meta($id, 'lsx_wetu_modified_date', strtotime($data[0]['last_modified'])); |
|
583 | 583 | } |
584 | 584 | } |
585 | 585 | |
586 | 586 | //Setup some default for use in the import |
587 | - if ( false !== $importable_content && (in_array( 'gallery',$importable_content ) || in_array( 'banner_image',$importable_content ) || in_array( 'featured_image',$importable_content )) ) { |
|
588 | - $this->find_attachments( $id ); |
|
587 | + if (false !== $importable_content && (in_array('gallery', $importable_content) || in_array('banner_image', $importable_content) || in_array('featured_image', $importable_content))) { |
|
588 | + $this->find_attachments($id); |
|
589 | 589 | } |
590 | 590 | |
591 | 591 | //Set the team member if it is there |
592 | - if ( post_type_exists( 'team' ) && false !== $team_members && '' !== $team_members ) { |
|
593 | - $this->set_team_member( $id,$team_members ); |
|
592 | + if (post_type_exists('team') && false !== $team_members && '' !== $team_members) { |
|
593 | + $this->set_team_member($id, $team_members); |
|
594 | 594 | } |
595 | 595 | |
596 | 596 | //Set the safari brand |
597 | - if ( false !== $safari_brands && '' !== $safari_brands ) { |
|
598 | - $this->set_safari_brands( $id,$safari_brands ); |
|
597 | + if (false !== $safari_brands && '' !== $safari_brands) { |
|
598 | + $this->set_safari_brands($id, $safari_brands); |
|
599 | 599 | } |
600 | 600 | |
601 | - if ( class_exists( 'LSX_TO_Maps' ) ) { |
|
602 | - $this->set_map_data( $data,$id,9 ); |
|
601 | + if (class_exists('LSX_TO_Maps')) { |
|
602 | + $this->set_map_data($data, $id, 9); |
|
603 | 603 | } |
604 | 604 | |
605 | - if ( post_type_exists( 'destination' ) && false !== $importable_content && in_array( 'destination',$importable_content ) ) { |
|
606 | - $this->connect_destinations( $data,$id ); |
|
605 | + if (post_type_exists('destination') && false !== $importable_content && in_array('destination', $importable_content)) { |
|
606 | + $this->connect_destinations($data, $id); |
|
607 | 607 | } |
608 | 608 | |
609 | - if ( false !== $importable_content && in_array( 'category',$importable_content ) ) { |
|
610 | - $this->set_taxonomy_style( $data,$id ); |
|
609 | + if (false !== $importable_content && in_array('category', $importable_content)) { |
|
610 | + $this->set_taxonomy_style($data, $id); |
|
611 | 611 | } |
612 | 612 | |
613 | 613 | //Set the Room Data |
614 | - if ( false !== $importable_content && in_array( 'rooms',$importable_content ) ) { |
|
615 | - $this->set_room_data( $data,$id ); |
|
614 | + if (false !== $importable_content && in_array('rooms', $importable_content)) { |
|
615 | + $this->set_room_data($data, $id); |
|
616 | 616 | } |
617 | 617 | |
618 | 618 | //Set the rating |
619 | - if ( false !== $importable_content && in_array( 'rating',$importable_content ) ) { |
|
620 | - $this->set_rating( $data,$id ); |
|
619 | + if (false !== $importable_content && in_array('rating', $importable_content)) { |
|
620 | + $this->set_rating($data, $id); |
|
621 | 621 | } |
622 | 622 | |
623 | 623 | //Set the checkin checkout data |
624 | - if ( false !== $importable_content && in_array( 'checkin',$importable_content ) ) { |
|
625 | - $this->set_checkin_checkout( $data,$id ); |
|
624 | + if (false !== $importable_content && in_array('checkin', $importable_content)) { |
|
625 | + $this->set_checkin_checkout($data, $id); |
|
626 | 626 | } |
627 | 627 | |
628 | 628 | //Set the Spoken Languages |
629 | - if ( false !== $importable_content && in_array( 'spoken_languages',$importable_content ) ) { |
|
630 | - $this->set_spoken_languages( $data,$id ); |
|
629 | + if (false !== $importable_content && in_array('spoken_languages', $importable_content)) { |
|
630 | + $this->set_spoken_languages($data, $id); |
|
631 | 631 | } |
632 | 632 | |
633 | 633 | //Set the friendly options |
634 | - if ( false !== $importable_content && in_array( 'friendly',$importable_content ) ) { |
|
635 | - $this->set_friendly( $data,$id ); |
|
634 | + if (false !== $importable_content && in_array('friendly', $importable_content)) { |
|
635 | + $this->set_friendly($data, $id); |
|
636 | 636 | } |
637 | 637 | |
638 | 638 | //Set the special_interests |
639 | - if ( false !== $importable_content && in_array( 'special_interests',$importable_content ) ) { |
|
640 | - $this->set_special_interests( $data,$id ); |
|
639 | + if (false !== $importable_content && in_array('special_interests', $importable_content)) { |
|
640 | + $this->set_special_interests($data, $id); |
|
641 | 641 | } |
642 | 642 | |
643 | 643 | //Import the videos |
644 | - if ( false !== $importable_content && in_array( 'videos',$importable_content ) ) { |
|
645 | - $this->set_video_data( $data,$id ); |
|
644 | + if (false !== $importable_content && in_array('videos', $importable_content)) { |
|
645 | + $this->set_video_data($data, $id); |
|
646 | 646 | } |
647 | 647 | |
648 | 648 | //Import the facilities |
649 | - if ( false !== $importable_content && in_array( 'facilities',$importable_content ) ) { |
|
650 | - $this->set_facilities( $data,$id ); |
|
649 | + if (false !== $importable_content && in_array('facilities', $importable_content)) { |
|
650 | + $this->set_facilities($data, $id); |
|
651 | 651 | } |
652 | 652 | |
653 | 653 | //Set the featured image |
654 | - if ( false !== $importable_content && in_array( 'featured_image',$importable_content ) ) { |
|
655 | - $this->set_featured_image( $data,$id ); |
|
654 | + if (false !== $importable_content && in_array('featured_image', $importable_content)) { |
|
655 | + $this->set_featured_image($data, $id); |
|
656 | 656 | } |
657 | 657 | |
658 | - if ( false !== $importable_content && in_array( 'banner_image',$importable_content ) ) { |
|
659 | - $this->set_banner_image( $data,$id ); |
|
658 | + if (false !== $importable_content && in_array('banner_image', $importable_content)) { |
|
659 | + $this->set_banner_image($data, $id); |
|
660 | 660 | } |
661 | 661 | |
662 | 662 | //Import the main gallery |
663 | - if ( false !== $importable_content && in_array( 'gallery',$importable_content ) ) { |
|
664 | - $this->create_main_gallery( $data,$id ); |
|
663 | + if (false !== $importable_content && in_array('gallery', $importable_content)) { |
|
664 | + $this->create_main_gallery($data, $id); |
|
665 | 665 | } |
666 | 666 | |
667 | 667 | return $id; |
@@ -670,58 +670,58 @@ discard block |
||
670 | 670 | /** |
671 | 671 | * Set the team memberon each item. |
672 | 672 | */ |
673 | - public function set_team_member( $id, $team_members ) { |
|
674 | - delete_post_meta( $id, 'team_to_' . $this->tab_slug ); |
|
673 | + public function set_team_member($id, $team_members) { |
|
674 | + delete_post_meta($id, 'team_to_'.$this->tab_slug); |
|
675 | 675 | |
676 | - foreach ( $team_members as $team ) { |
|
677 | - add_post_meta( $id,'team_to_' . $this->tab_slug,$team ); |
|
676 | + foreach ($team_members as $team) { |
|
677 | + add_post_meta($id, 'team_to_'.$this->tab_slug, $team); |
|
678 | 678 | } |
679 | 679 | } |
680 | 680 | |
681 | 681 | /** |
682 | 682 | * Set the safari brand |
683 | 683 | */ |
684 | - public function set_safari_brands( $id, $safari_brands ) { |
|
685 | - foreach ( $safari_brands as $safari_brand ) { |
|
686 | - wp_set_object_terms( $id, intval( $safari_brand ), 'accommodation-brand',true ); |
|
684 | + public function set_safari_brands($id, $safari_brands) { |
|
685 | + foreach ($safari_brands as $safari_brand) { |
|
686 | + wp_set_object_terms($id, intval($safari_brand), 'accommodation-brand', true); |
|
687 | 687 | } |
688 | 688 | } |
689 | 689 | |
690 | 690 | /** |
691 | 691 | * Connects the destinations post type |
692 | 692 | */ |
693 | - public function connect_destinations( $data, $id ) { |
|
694 | - if ( isset( $data[0]['position'] ) ) { |
|
693 | + public function connect_destinations($data, $id) { |
|
694 | + if (isset($data[0]['position'])) { |
|
695 | 695 | $destinations = false; |
696 | 696 | |
697 | - if ( isset( $data[0]['position']['country'] ) ) { |
|
697 | + if (isset($data[0]['position']['country'])) { |
|
698 | 698 | $destinations['country'] = $data[0]['position']['country']; |
699 | 699 | } |
700 | 700 | |
701 | - if ( isset( $data[0]['position']['destination'] ) ) { |
|
701 | + if (isset($data[0]['position']['destination'])) { |
|
702 | 702 | $destinations['destination'] = $data[0]['position']['destination']; |
703 | 703 | } |
704 | 704 | |
705 | - if ( false !== $destinations ) { |
|
706 | - $prev_values = get_post_meta( $id,'destination_to_accommodation',false ); |
|
705 | + if (false !== $destinations) { |
|
706 | + $prev_values = get_post_meta($id, 'destination_to_accommodation', false); |
|
707 | 707 | |
708 | - if ( false === $prev_values || ! is_array( $prev_values ) ) { |
|
708 | + if (false === $prev_values || !is_array($prev_values)) { |
|
709 | 709 | $prev_values = array(); |
710 | 710 | } |
711 | 711 | |
712 | - delete_post_meta( $id,'destination_to_accommodation',$prev_values ); |
|
712 | + delete_post_meta($id, 'destination_to_accommodation', $prev_values); |
|
713 | 713 | |
714 | 714 | //print_r($destinations); |
715 | - $destinations = array_unique( $destinations ); |
|
715 | + $destinations = array_unique($destinations); |
|
716 | 716 | //print_r($destinations); |
717 | 717 | |
718 | - foreach ( $destinations as $key => $value ) { |
|
719 | - $destination = get_page_by_title( ltrim( rtrim( $value ) ), 'OBJECT', 'destination' ); |
|
720 | - if ( null !== $destination ) { |
|
721 | - if ( ! in_array( $destination->ID,$prev_values ) ) { |
|
722 | - add_post_meta( $id,'destination_to_accommodation',$destination->ID,false ); |
|
723 | - add_post_meta( $destination->ID,'accommodation_to_destination',$id,false ); |
|
724 | - $this->cleanup_posts[ $destination->ID ] = 'accommodation_to_destination'; |
|
718 | + foreach ($destinations as $key => $value) { |
|
719 | + $destination = get_page_by_title(ltrim(rtrim($value)), 'OBJECT', 'destination'); |
|
720 | + if (null !== $destination) { |
|
721 | + if (!in_array($destination->ID, $prev_values)) { |
|
722 | + add_post_meta($id, 'destination_to_accommodation', $destination->ID, false); |
|
723 | + add_post_meta($destination->ID, 'accommodation_to_destination', $id, false); |
|
724 | + $this->cleanup_posts[$destination->ID] = 'accommodation_to_destination'; |
|
725 | 725 | } |
726 | 726 | } |
727 | 727 | } |
@@ -732,50 +732,50 @@ discard block |
||
732 | 732 | /** |
733 | 733 | * Set the Travel Style |
734 | 734 | */ |
735 | - public function set_taxonomy_style( $data, $id ) { |
|
735 | + public function set_taxonomy_style($data, $id) { |
|
736 | 736 | $terms = false; |
737 | 737 | |
738 | - if ( isset( $data[0]['category'] ) ) { |
|
738 | + if (isset($data[0]['category'])) { |
|
739 | 739 | // @codingStandardsIgnoreLine |
740 | - if ( ! $term = term_exists( trim( $data[0]['category'] ), 'accommodation-type' ) ) { |
|
741 | - $term = wp_insert_term( trim( $data[0]['category'] ), 'accommodation-type' ); |
|
740 | + if (!$term = term_exists(trim($data[0]['category']), 'accommodation-type')) { |
|
741 | + $term = wp_insert_term(trim($data[0]['category']), 'accommodation-type'); |
|
742 | 742 | |
743 | - if ( is_wp_error( $term ) ) { |
|
743 | + if (is_wp_error($term)) { |
|
744 | 744 | // @codingStandardsIgnoreLine |
745 | 745 | echo $term->get_error_message(); |
746 | 746 | } |
747 | - } else { |
|
748 | - wp_set_object_terms( $id, intval( $term['term_id'] ), 'accommodation-type',true ); |
|
747 | + }else { |
|
748 | + wp_set_object_terms($id, intval($term['term_id']), 'accommodation-type', true); |
|
749 | 749 | } |
750 | - } else { |
|
751 | - wp_set_object_terms( $id, intval( $term['term_id'] ), 'accommodation-type',true ); |
|
750 | + }else { |
|
751 | + wp_set_object_terms($id, intval($term['term_id']), 'accommodation-type', true); |
|
752 | 752 | } |
753 | 753 | } |
754 | 754 | |
755 | 755 | /** |
756 | 756 | * Saves the room data |
757 | 757 | */ |
758 | - public function set_room_data( $data, $id ) { |
|
759 | - if ( ! empty( $data[0]['rooms'] ) && is_array( $data[0]['rooms'] ) ) { |
|
758 | + public function set_room_data($data, $id) { |
|
759 | + if (!empty($data[0]['rooms']) && is_array($data[0]['rooms'])) { |
|
760 | 760 | $rooms = false; |
761 | 761 | |
762 | - foreach ( $data[0]['rooms'] as $room ) { |
|
762 | + foreach ($data[0]['rooms'] as $room) { |
|
763 | 763 | $temp_room = array(); |
764 | 764 | |
765 | - if ( isset( $room['name'] ) ) { |
|
765 | + if (isset($room['name'])) { |
|
766 | 766 | $temp_room['title'] = $room['name']; |
767 | 767 | } |
768 | 768 | |
769 | - if ( isset( $room['description'] ) ) { |
|
770 | - $temp_room['description'] = strip_tags( $room['description'] ); |
|
769 | + if (isset($room['description'])) { |
|
770 | + $temp_room['description'] = strip_tags($room['description']); |
|
771 | 771 | } |
772 | 772 | |
773 | 773 | $temp_room['price'] = 0; |
774 | 774 | $temp_room['type'] = 'room'; |
775 | 775 | |
776 | - if ( ! empty( $room['images'] ) && is_array( $room['images'] ) ) { |
|
776 | + if (!empty($room['images']) && is_array($room['images'])) { |
|
777 | 777 | $temp_room['gallery'] = array(); |
778 | - $temp_room['gallery'][] = $this->attach_image( $room['images'][0], $id ); |
|
778 | + $temp_room['gallery'][] = $this->attach_image($room['images'][0], $id); |
|
779 | 779 | |
780 | 780 | /*foreach($room['images'] as $image_data){ |
781 | 781 | $temp_room['gallery'][] = $this->attach_image($image_data,$id); |
@@ -785,25 +785,25 @@ discard block |
||
785 | 785 | $rooms[] = $temp_room; |
786 | 786 | } |
787 | 787 | |
788 | - if ( false !== $id && '0' !== $id ) { |
|
789 | - delete_post_meta( $id, 'units' ); |
|
788 | + if (false !== $id && '0' !== $id) { |
|
789 | + delete_post_meta($id, 'units'); |
|
790 | 790 | } |
791 | 791 | |
792 | - foreach ( $rooms as $room ) { |
|
793 | - add_post_meta( $id,'units',$room,false ); |
|
792 | + foreach ($rooms as $room) { |
|
793 | + add_post_meta($id, 'units', $room, false); |
|
794 | 794 | } |
795 | 795 | |
796 | - if ( isset( $data[0]['features'] ) && isset( $data[0]['features']['rooms'] ) ) { |
|
796 | + if (isset($data[0]['features']) && isset($data[0]['features']['rooms'])) { |
|
797 | 797 | $room_count = $data[0]['features']['rooms']; |
798 | - } else { |
|
799 | - $room_count = count( $data[0]['rooms'] ); |
|
798 | + }else { |
|
799 | + $room_count = count($data[0]['rooms']); |
|
800 | 800 | } |
801 | 801 | |
802 | - if ( false !== $id && '0' !== $id ) { |
|
803 | - $prev_rooms = get_post_meta( $id,'number_of_rooms',true ); |
|
804 | - update_post_meta( $id,'number_of_rooms',$room_count,$prev_rooms ); |
|
805 | - } else { |
|
806 | - add_post_meta( $id,'number_of_rooms',$room_count,true ); |
|
802 | + if (false !== $id && '0' !== $id) { |
|
803 | + $prev_rooms = get_post_meta($id, 'number_of_rooms', true); |
|
804 | + update_post_meta($id, 'number_of_rooms', $room_count, $prev_rooms); |
|
805 | + }else { |
|
806 | + add_post_meta($id, 'number_of_rooms', $room_count, true); |
|
807 | 807 | } |
808 | 808 | } |
809 | 809 | } |
@@ -811,33 +811,33 @@ discard block |
||
811 | 811 | /** |
812 | 812 | * Set the ratings |
813 | 813 | */ |
814 | - public function set_rating( $data, $id ) { |
|
815 | - if ( ! empty( $data[0]['features'] ) && isset( $data[0]['features']['star_authority'] ) ) { |
|
814 | + public function set_rating($data, $id) { |
|
815 | + if (!empty($data[0]['features']) && isset($data[0]['features']['star_authority'])) { |
|
816 | 816 | $rating_type = $data[0]['features']['star_authority']; |
817 | - } else { |
|
817 | + }else { |
|
818 | 818 | $rating_type = 'Unspecified2'; |
819 | 819 | } |
820 | 820 | |
821 | - $this->save_custom_field( $rating_type,'rating_type',$id ); |
|
821 | + $this->save_custom_field($rating_type, 'rating_type', $id); |
|
822 | 822 | |
823 | - if ( ! empty( $data[0]['features'] ) && isset( $data[0]['features']['stars'] ) ) { |
|
824 | - $this->save_custom_field( $data[0]['features']['stars'],'rating',$id,true ); |
|
823 | + if (!empty($data[0]['features']) && isset($data[0]['features']['stars'])) { |
|
824 | + $this->save_custom_field($data[0]['features']['stars'], 'rating', $id, true); |
|
825 | 825 | } |
826 | 826 | } |
827 | 827 | |
828 | 828 | /** |
829 | 829 | * Set the spoken_languages |
830 | 830 | */ |
831 | - public function set_spoken_languages( $data, $id ) { |
|
832 | - if ( ! empty( $data[0]['features'] ) && isset( $data[0]['features']['spoken_languages'] ) && ! empty( $data[0]['features']['spoken_languages'] ) ) { |
|
831 | + public function set_spoken_languages($data, $id) { |
|
832 | + if (!empty($data[0]['features']) && isset($data[0]['features']['spoken_languages']) && !empty($data[0]['features']['spoken_languages'])) { |
|
833 | 833 | $languages = false; |
834 | 834 | |
835 | - foreach ( $data[0]['features']['spoken_languages'] as $spoken_language ) { |
|
836 | - $languages[] = sanitize_title( $spoken_language ); |
|
835 | + foreach ($data[0]['features']['spoken_languages'] as $spoken_language) { |
|
836 | + $languages[] = sanitize_title($spoken_language); |
|
837 | 837 | } |
838 | 838 | |
839 | - if ( false !== $languages ) { |
|
840 | - $this->save_custom_field( $languages,'spoken_languages',$id ); |
|
839 | + if (false !== $languages) { |
|
840 | + $this->save_custom_field($languages, 'spoken_languages', $id); |
|
841 | 841 | } |
842 | 842 | } |
843 | 843 | } |
@@ -845,16 +845,16 @@ discard block |
||
845 | 845 | /** |
846 | 846 | * Set the friendly |
847 | 847 | */ |
848 | - public function set_friendly( $data, $id ) { |
|
849 | - if ( ! empty( $data[0]['features'] ) && isset( $data[0]['features']['suggested_visitor_types'] ) && ! empty( $data[0]['features']['suggested_visitor_types'] ) ) { |
|
848 | + public function set_friendly($data, $id) { |
|
849 | + if (!empty($data[0]['features']) && isset($data[0]['features']['suggested_visitor_types']) && !empty($data[0]['features']['suggested_visitor_types'])) { |
|
850 | 850 | $friendly_options = false; |
851 | 851 | |
852 | - foreach ( $data[0]['features']['suggested_visitor_types'] as $visitor_type ) { |
|
853 | - $friendly_options[] = sanitize_title( $visitor_type ); |
|
852 | + foreach ($data[0]['features']['suggested_visitor_types'] as $visitor_type) { |
|
853 | + $friendly_options[] = sanitize_title($visitor_type); |
|
854 | 854 | } |
855 | 855 | |
856 | - if ( false !== $friendly_options ) { |
|
857 | - $this->save_custom_field( $friendly_options,'suggested_visitor_types',$id ); |
|
856 | + if (false !== $friendly_options) { |
|
857 | + $this->save_custom_field($friendly_options, 'suggested_visitor_types', $id); |
|
858 | 858 | } |
859 | 859 | } |
860 | 860 | } |
@@ -862,16 +862,16 @@ discard block |
||
862 | 862 | /** |
863 | 863 | * Set the special interests |
864 | 864 | */ |
865 | - public function set_special_interests( $data, $id ) { |
|
866 | - if ( ! empty( $data[0]['features'] ) && isset( $data[0]['features']['special_interests'] ) && ! empty( $data[0]['features']['special_interests'] ) ) { |
|
865 | + public function set_special_interests($data, $id) { |
|
866 | + if (!empty($data[0]['features']) && isset($data[0]['features']['special_interests']) && !empty($data[0]['features']['special_interests'])) { |
|
867 | 867 | $interests = false; |
868 | 868 | |
869 | - foreach ( $data[0]['features']['special_interests'] as $special_interest ) { |
|
870 | - $interests[] = sanitize_title( $special_interest ); |
|
869 | + foreach ($data[0]['features']['special_interests'] as $special_interest) { |
|
870 | + $interests[] = sanitize_title($special_interest); |
|
871 | 871 | } |
872 | 872 | |
873 | - if ( false !== $interests ) { |
|
874 | - $this->save_custom_field( $interests,'special_interests',$id ); |
|
873 | + if (false !== $interests) { |
|
874 | + $this->save_custom_field($interests, 'special_interests', $id); |
|
875 | 875 | } |
876 | 876 | } |
877 | 877 | } |
@@ -879,24 +879,24 @@ discard block |
||
879 | 879 | /** |
880 | 880 | * Set the Check in and Check out Date |
881 | 881 | */ |
882 | - public function set_checkin_checkout( $data, $id ) { |
|
883 | - if ( ! empty( $data[0]['features'] ) && isset( $data[0]['features']['check_in_time'] ) ) { |
|
884 | - $time = str_replace( 'h',':',$data[0]['features']['check_in_time'] ); |
|
885 | - $time = date( 'h:ia',strtotime( $time ) ); |
|
886 | - $this->save_custom_field( $time,'checkin_time',$id ); |
|
882 | + public function set_checkin_checkout($data, $id) { |
|
883 | + if (!empty($data[0]['features']) && isset($data[0]['features']['check_in_time'])) { |
|
884 | + $time = str_replace('h', ':', $data[0]['features']['check_in_time']); |
|
885 | + $time = date('h:ia', strtotime($time)); |
|
886 | + $this->save_custom_field($time, 'checkin_time', $id); |
|
887 | 887 | } |
888 | 888 | |
889 | - if ( ! empty( $data[0]['features'] ) && isset( $data[0]['features']['check_out_time'] ) ) { |
|
890 | - $time = str_replace( 'h',':',$data[0]['features']['check_out_time'] ); |
|
891 | - $time = date( 'h:ia',strtotime( $time ) ); |
|
892 | - $this->save_custom_field( $time,'checkout_time',$id ); |
|
889 | + if (!empty($data[0]['features']) && isset($data[0]['features']['check_out_time'])) { |
|
890 | + $time = str_replace('h', ':', $data[0]['features']['check_out_time']); |
|
891 | + $time = date('h:ia', strtotime($time)); |
|
892 | + $this->save_custom_field($time, 'checkout_time', $id); |
|
893 | 893 | } |
894 | 894 | } |
895 | 895 | |
896 | 896 | /** |
897 | 897 | * Set the Facilities |
898 | 898 | */ |
899 | - public function set_facilities( $data, $id ) { |
|
899 | + public function set_facilities($data, $id) { |
|
900 | 900 | $parent_facilities = array( |
901 | 901 | 'available_services' => 'Available Services', |
902 | 902 | 'property_facilities' => 'Property Facilities', |
@@ -904,15 +904,15 @@ discard block |
||
904 | 904 | 'activities_on_site' => 'Activities on Site', |
905 | 905 | ); |
906 | 906 | |
907 | - foreach ( $parent_facilities as $key => $label ) { |
|
907 | + foreach ($parent_facilities as $key => $label) { |
|
908 | 908 | $terms = false; |
909 | 909 | |
910 | - if ( isset( $data[0]['features'] ) && isset( $data[0]['features'][ $key ] ) ) { |
|
911 | - $parent_id = $this->set_term( $id,$label,'facility' ); |
|
910 | + if (isset($data[0]['features']) && isset($data[0]['features'][$key])) { |
|
911 | + $parent_id = $this->set_term($id, $label, 'facility'); |
|
912 | 912 | } |
913 | 913 | |
914 | - foreach ( $data[0]['features'][ $key ] as $child_facility ) { |
|
915 | - $this->set_term( $id,$child_facility,'facility',$parent_id ); |
|
914 | + foreach ($data[0]['features'][$key] as $child_facility) { |
|
915 | + $this->set_term($id, $child_facility, 'facility', $parent_id); |
|
916 | 916 | } |
917 | 917 | } |
918 | 918 | } |