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