@@ -52,33 +52,33 @@ discard block |
||
52 | 52 | * @access private |
53 | 53 | */ |
54 | 54 | public function __construct() { |
55 | - add_action( 'admin_enqueue_scripts', array($this,'admin_scripts') ,11 ); |
|
56 | - add_action( 'admin_menu', array( $this, 'register_importer_page' ),20 ); |
|
55 | + add_action('admin_enqueue_scripts', array($this, 'admin_scripts'), 11); |
|
56 | + add_action('admin_menu', array($this, 'register_importer_page'), 20); |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | /** |
60 | 60 | * Registers the admin page which will house the importer form. |
61 | 61 | */ |
62 | 62 | public function register_importer_page() { |
63 | - add_submenu_page( 'tour-operator',esc_html__( 'Importer', 'tour-operator' ), esc_html__( 'Importer', 'tour-operator' ), 'manage_options', 'wetu-importer', array( $this, 'display_page' ) ); |
|
63 | + add_submenu_page('tour-operator', esc_html__('Importer', 'tour-operator'), esc_html__('Importer', 'tour-operator'), 'manage_options', 'wetu-importer', array($this, 'display_page')); |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | /** |
67 | 67 | * Enqueue the JS needed to contact wetu and return your result. |
68 | 68 | */ |
69 | 69 | public function admin_scripts() { |
70 | - if ( defined( 'WP_DEBUG' ) && true === WP_DEBUG ) { |
|
70 | + if (defined('WP_DEBUG') && true === WP_DEBUG) { |
|
71 | 71 | $min = ''; |
72 | - } else { |
|
72 | + }else { |
|
73 | 73 | $min = '.min'; |
74 | 74 | } |
75 | 75 | $min = ''; |
76 | 76 | |
77 | - if(is_admin() && isset($_GET['page']) && $this->plugin_slug === $_GET['page']){ |
|
78 | - wp_enqueue_script( 'wetu-importers-script', WETU_IMPORTER_URL . 'assets/js/wetu-importer' . $min . '.js', array( 'jquery' ), WETU_IMPORTER_VER, true ); |
|
79 | - wp_localize_script( 'wetu-importers-script', 'lsx_tour_importer_params', array( |
|
77 | + if (is_admin() && isset($_GET['page']) && $this->plugin_slug === $_GET['page']) { |
|
78 | + wp_enqueue_script('wetu-importers-script', WETU_IMPORTER_URL.'assets/js/wetu-importer'.$min.'.js', array('jquery'), WETU_IMPORTER_VER, true); |
|
79 | + wp_localize_script('wetu-importers-script', 'lsx_tour_importer_params', array( |
|
80 | 80 | 'ajax_url' => admin_url('admin-ajax.php'), |
81 | - ) ); |
|
81 | + )); |
|
82 | 82 | } |
83 | 83 | } |
84 | 84 | |
@@ -90,24 +90,24 @@ discard block |
||
90 | 90 | <div class="wrap"> |
91 | 91 | <?php screen_icon(); ?> |
92 | 92 | |
93 | - <?php if(!isset($_GET['tab'])){ ?> |
|
94 | - <h2><?php _e('Welcome to the LSX Wetu Importer','wetu-importer'); ?></h2> |
|
93 | + <?php if (!isset($_GET['tab'])) { ?> |
|
94 | + <h2><?php _e('Welcome to the LSX Wetu Importer', 'wetu-importer'); ?></h2> |
|
95 | 95 | <p>If this is the first time you are running the import, then follow the steps below.</p> |
96 | 96 | <ul> |
97 | - <li>Step 1 - Import your <a href="<?php echo admin_url('admin.php'); ?>?page=<?php echo $this->plugin_slug; ?>&tab=tour"><?php _e('Tours','wetu-importer'); ?></a></li> |
|
98 | - <li>Step 2 - The tour import will have created draft <a href="<?php echo admin_url('admin.php'); ?>?page=<?php echo $this->plugin_slug; ?>&tab=accommodation"><?php _e('accommodation','wetu-importer'); ?></a> that will need to be imported.</li> |
|
99 | - <li>Step 3 - Lastly import the <a href="<?php echo admin_url('admin.php'); ?>?page=<?php echo $this->plugin_slug; ?>&tab=destination"><?php _e('destinations','wetu-importer'); ?></a> draft posts created during the previous two steps.</li> |
|
97 | + <li>Step 1 - Import your <a href="<?php echo admin_url('admin.php'); ?>?page=<?php echo $this->plugin_slug; ?>&tab=tour"><?php _e('Tours', 'wetu-importer'); ?></a></li> |
|
98 | + <li>Step 2 - The tour import will have created draft <a href="<?php echo admin_url('admin.php'); ?>?page=<?php echo $this->plugin_slug; ?>&tab=accommodation"><?php _e('accommodation', 'wetu-importer'); ?></a> that will need to be imported.</li> |
|
99 | + <li>Step 3 - Lastly import the <a href="<?php echo admin_url('admin.php'); ?>?page=<?php echo $this->plugin_slug; ?>&tab=destination"><?php _e('destinations', 'wetu-importer'); ?></a> draft posts created during the previous two steps.</li> |
|
100 | 100 | </ul> |
101 | 101 | |
102 | - <h3><?php _e('Additional Tools','wetu-importer'); ?></h3> |
|
102 | + <h3><?php _e('Additional Tools', 'wetu-importer'); ?></h3> |
|
103 | 103 | <ul> |
104 | - <li><a href="<?php echo admin_url('admin.php'); ?>?page=<?php echo $this->plugin_slug; ?>&tab=connect_accommodation"><?php _e('Connect Accommodation','wetu-importer'); ?></a> <small><?php _e('If you already have accommodation, you can "connect" it with its WETU counter part, so it works with the importer.','wetu-importer'); ?></small></li> |
|
105 | - <?php if(class_exists('Lsx_Banners')){ ?> |
|
106 | - <li><a href="<?php echo admin_url('admin.php'); ?>?page=<?php echo $this->plugin_slug; ?>&tab=banners"><?php _e('Sync High Res Banner Images','wetu-importer'); ?></a></li> |
|
104 | + <li><a href="<?php echo admin_url('admin.php'); ?>?page=<?php echo $this->plugin_slug; ?>&tab=connect_accommodation"><?php _e('Connect Accommodation', 'wetu-importer'); ?></a> <small><?php _e('If you already have accommodation, you can "connect" it with its WETU counter part, so it works with the importer.', 'wetu-importer'); ?></small></li> |
|
105 | + <?php if (class_exists('Lsx_Banners')) { ?> |
|
106 | + <li><a href="<?php echo admin_url('admin.php'); ?>?page=<?php echo $this->plugin_slug; ?>&tab=banners"><?php _e('Sync High Res Banner Images', 'wetu-importer'); ?></a></li> |
|
107 | 107 | <?php } ?> |
108 | 108 | </ul> |
109 | 109 | |
110 | - <?php } else { |
|
110 | + <?php }else { |
|
111 | 111 | do_action('lsx_tour_importer_admin_tab_'.$_GET['tab']); |
112 | 112 | } ?> |
113 | 113 | </div> |
@@ -155,34 +155,34 @@ discard block |
||
155 | 155 | /** |
156 | 156 | * set_taxonomy with some terms |
157 | 157 | */ |
158 | - public function set_taxonomy($taxonomy,$terms,$id) { |
|
159 | - $result=array(); |
|
160 | - if(!empty($data)) |
|
158 | + public function set_taxonomy($taxonomy, $terms, $id) { |
|
159 | + $result = array(); |
|
160 | + if (!empty($data)) |
|
161 | 161 | { |
162 | - foreach($data as $k) |
|
162 | + foreach ($data as $k) |
|
163 | 163 | { |
164 | - if($id) |
|
164 | + if ($id) |
|
165 | 165 | { |
166 | - if(!$term = term_exists(trim($k), $tax)) |
|
166 | + if (!$term = term_exists(trim($k), $tax)) |
|
167 | 167 | { |
168 | 168 | $term = wp_insert_term(trim($k), $tax); |
169 | - if ( is_wp_error($term) ) |
|
169 | + if (is_wp_error($term)) |
|
170 | 170 | { |
171 | 171 | echo $term->get_error_message(); |
172 | 172 | } |
173 | 173 | else |
174 | 174 | { |
175 | - wp_set_object_terms( $id, intval($term['term_id']), $taxonomy,true); |
|
175 | + wp_set_object_terms($id, intval($term['term_id']), $taxonomy, true); |
|
176 | 176 | } |
177 | 177 | } |
178 | 178 | else |
179 | 179 | { |
180 | - wp_set_object_terms( $id, intval($term['term_id']), $taxonomy,true); |
|
180 | + wp_set_object_terms($id, intval($term['term_id']), $taxonomy, true); |
|
181 | 181 | } |
182 | 182 | } |
183 | 183 | else |
184 | 184 | { |
185 | - $result[]=trim($k); |
|
185 | + $result[] = trim($k); |
|
186 | 186 | } |
187 | 187 | } |
188 | 188 | } |
@@ -192,23 +192,23 @@ discard block |
||
192 | 192 | /** |
193 | 193 | * set_taxonomy with some terms |
194 | 194 | */ |
195 | - public function team_member_checkboxes($selected=array()) { |
|
196 | - if(post_type_exists('team')) { ?> |
|
195 | + public function team_member_checkboxes($selected = array()) { |
|
196 | + if (post_type_exists('team')) { ?> |
|
197 | 197 | <ul> |
198 | 198 | <?php |
199 | - $team_args=array( |
|
199 | + $team_args = array( |
|
200 | 200 | 'post_type' => 'team', |
201 | 201 | 'post_status' => 'publish', |
202 | 202 | 'nopagin' => true, |
203 | 203 | 'fields' => 'ids' |
204 | 204 | ); |
205 | 205 | $team_members = new WP_Query($team_args); |
206 | - if($team_members->have_posts()){ |
|
207 | - foreach($team_members->posts as $member){ ?> |
|
208 | - <li><input class="team" <?php $this->checked($selected,$member); ?> type="checkbox" value="<?php echo $member; ?>" /> <?php echo get_the_title($member); ?></li> |
|
206 | + if ($team_members->have_posts()) { |
|
207 | + foreach ($team_members->posts as $member) { ?> |
|
208 | + <li><input class="team" <?php $this->checked($selected, $member); ?> type="checkbox" value="<?php echo $member; ?>" /> <?php echo get_the_title($member); ?></li> |
|
209 | 209 | <?php } |
210 | - }else{ ?> |
|
211 | - <li><input class="team" type="checkbox" value="0" /> <?php _e('None','wetu-importer'); ?></li> |
|
210 | + }else { ?> |
|
211 | + <li><input class="team" type="checkbox" value="0" /> <?php _e('None', 'wetu-importer'); ?></li> |
|
212 | 212 | <?php } |
213 | 213 | ?> |
214 | 214 | </ul> |
@@ -218,18 +218,18 @@ discard block |
||
218 | 218 | /** |
219 | 219 | * set_taxonomy with some terms |
220 | 220 | */ |
221 | - public function taxonomy_checkboxes($taxonomy=false,$selected=array()) { |
|
221 | + public function taxonomy_checkboxes($taxonomy = false, $selected = array()) { |
|
222 | 222 | $return = ''; |
223 | - if(false !== $taxonomy){ |
|
223 | + if (false !== $taxonomy) { |
|
224 | 224 | $return .= '<ul>'; |
225 | - $terms = get_terms(array('taxonomy'=>$taxonomy,'hide_empty'=>false)); |
|
225 | + $terms = get_terms(array('taxonomy'=>$taxonomy, 'hide_empty'=>false)); |
|
226 | 226 | |
227 | - if(!is_wp_error($terms)){ |
|
228 | - foreach($terms as $term){ |
|
229 | - $return .= '<li><input class="'.$taxonomy.'" '.$this->checked($selected,$term->term_id,false).' type="checkbox" value="'.$term->term_id.'" /> '.$term->name.'</li>'; |
|
227 | + if (!is_wp_error($terms)) { |
|
228 | + foreach ($terms as $term) { |
|
229 | + $return .= '<li><input class="'.$taxonomy.'" '.$this->checked($selected, $term->term_id, false).' type="checkbox" value="'.$term->term_id.'" /> '.$term->name.'</li>'; |
|
230 | 230 | } |
231 | - }else{ |
|
232 | - $return .= '<li><input type="checkbox" value="" /> '.__('None','wetu-importer').'</li>'; |
|
231 | + }else { |
|
232 | + $return .= '<li><input type="checkbox" value="" /> '.__('None', 'wetu-importer').'</li>'; |
|
233 | 233 | } |
234 | 234 | $return .= '</ul>'; |
235 | 235 | } |
@@ -239,18 +239,18 @@ discard block |
||
239 | 239 | /** |
240 | 240 | * Saves the room data |
241 | 241 | */ |
242 | - public function save_custom_field($value=false,$meta_key,$id,$decrease=false,$unique=true) { |
|
243 | - if(false !== $value){ |
|
244 | - if(false !== $decrease){ |
|
242 | + public function save_custom_field($value = false, $meta_key, $id, $decrease = false, $unique = true) { |
|
243 | + if (false !== $value) { |
|
244 | + if (false !== $decrease) { |
|
245 | 245 | $value = intval($value); |
246 | 246 | $value--; |
247 | 247 | } |
248 | - $prev = get_post_meta($id,$meta_key,true); |
|
248 | + $prev = get_post_meta($id, $meta_key, true); |
|
249 | 249 | |
250 | - if(false !== $id && '0' !== $id && false !== $prev && true === $unique){ |
|
251 | - update_post_meta($id,$meta_key,$value,$prev); |
|
252 | - }else{ |
|
253 | - add_post_meta($id,$meta_key,$value,$unique); |
|
250 | + if (false !== $id && '0' !== $id && false !== $prev && true === $unique) { |
|
251 | + update_post_meta($id, $meta_key, $value, $prev); |
|
252 | + }else { |
|
253 | + add_post_meta($id, $meta_key, $value, $unique); |
|
254 | 254 | } |
255 | 255 | } |
256 | 256 | } |
@@ -258,9 +258,9 @@ discard block |
||
258 | 258 | /** |
259 | 259 | * grabs any attachments for the current item |
260 | 260 | */ |
261 | - public function find_attachments($id=false) { |
|
262 | - if(false !== $id){ |
|
263 | - if(empty($this->found_attachments)){ |
|
261 | + public function find_attachments($id = false) { |
|
262 | + if (false !== $id) { |
|
263 | + if (empty($this->found_attachments)) { |
|
264 | 264 | |
265 | 265 | $attachments_args = array( |
266 | 266 | 'post_parent' => $id, |
@@ -272,9 +272,9 @@ discard block |
||
272 | 272 | ); |
273 | 273 | |
274 | 274 | $attachments = new WP_Query($attachments_args); |
275 | - if($attachments->have_posts()){ |
|
276 | - foreach($attachments->posts as $attachment){ |
|
277 | - $this->found_attachments[$attachment->ID] = str_replace(array('.jpg','.png','.jpeg'),'',$attachment->post_title); |
|
275 | + if ($attachments->have_posts()) { |
|
276 | + foreach ($attachments->posts as $attachment) { |
|
277 | + $this->found_attachments[$attachment->ID] = str_replace(array('.jpg', '.png', '.jpeg'), '', $attachment->post_title); |
|
278 | 278 | $this->gallery_meta[] = $attachment->ID; |
279 | 279 | } |
280 | 280 | } |
@@ -289,12 +289,12 @@ discard block |
||
289 | 289 | * @param $needle string |
290 | 290 | * @param $echo bool |
291 | 291 | */ |
292 | - public function checked($haystack=false,$needle='',$echo=true) { |
|
293 | - $return = $this->itemd($haystack,$needle,'checked'); |
|
294 | - if('' !== $return) { |
|
292 | + public function checked($haystack = false, $needle = '', $echo = true) { |
|
293 | + $return = $this->itemd($haystack, $needle, 'checked'); |
|
294 | + if ('' !== $return) { |
|
295 | 295 | if (true === $echo) { |
296 | 296 | echo $return; |
297 | - } else { |
|
297 | + }else { |
|
298 | 298 | return $return; |
299 | 299 | } |
300 | 300 | } |
@@ -307,12 +307,12 @@ discard block |
||
307 | 307 | * @param $needle string |
308 | 308 | * @param $echo bool |
309 | 309 | */ |
310 | - public function selected($haystack=false,$needle='',$echo=true) { |
|
311 | - $return = $this->itemd($haystack,$needle,'selected'); |
|
312 | - if('' !== $return) { |
|
310 | + public function selected($haystack = false, $needle = '', $echo = true) { |
|
311 | + $return = $this->itemd($haystack, $needle, 'selected'); |
|
312 | + if ('' !== $return) { |
|
313 | 313 | if (true === $echo) { |
314 | 314 | echo $return; |
315 | - } else { |
|
315 | + }else { |
|
316 | 316 | return $return; |
317 | 317 | } |
318 | 318 | } |
@@ -327,16 +327,16 @@ discard block |
||
327 | 327 | * @param $wrap bool |
328 | 328 | * @return $html string |
329 | 329 | */ |
330 | - public function itemd($haystack=false,$needle='',$type='',$wrap=true) { |
|
330 | + public function itemd($haystack = false, $needle = '', $type = '', $wrap = true) { |
|
331 | 331 | $html = ''; |
332 | - if('' !== $type) { |
|
332 | + if ('' !== $type) { |
|
333 | 333 | if (!is_array($haystack)) { |
334 | 334 | $haystack = array($haystack); |
335 | 335 | } |
336 | 336 | if (in_array($needle, $haystack)) { |
337 | - if(true === $wrap || 'true' === $wrap) { |
|
338 | - $html = $type . '"' . $type . '"'; |
|
339 | - }else{ |
|
337 | + if (true === $wrap || 'true' === $wrap) { |
|
338 | + $html = $type.'"'.$type.'"'; |
|
339 | + }else { |
|
340 | 340 | $html = $type; |
341 | 341 | } |
342 | 342 | } |
@@ -350,17 +350,17 @@ discard block |
||
350 | 350 | * |
351 | 351 | * @param $tab string |
352 | 352 | */ |
353 | - public function navigation($tab='') { |
|
353 | + public function navigation($tab = '') { |
|
354 | 354 | $post_types = array( |
355 | - 'tour' => esc_attr('Tours','wetu-importer'), |
|
356 | - 'accommodation' => esc_attr('Accommodation','wetu-importer'), |
|
357 | - 'destination' => esc_attr('Destinations','wetu-importer'), |
|
355 | + 'tour' => esc_attr('Tours', 'wetu-importer'), |
|
356 | + 'accommodation' => esc_attr('Accommodation', 'wetu-importer'), |
|
357 | + 'destination' => esc_attr('Destinations', 'wetu-importer'), |
|
358 | 358 | ); |
359 | 359 | |
360 | 360 | |
361 | - echo '<div class="wet-navigation"><div class="subsubsub"><a class="'.$this->itemd($tab,'','current',false).'" href="'.admin_url('admin.php').'?page='.$this->plugin_slug.'">'.esc_attr('Home','wetu-importer').'</a>'; |
|
362 | - foreach($post_types as $post_type => $label){ |
|
363 | - echo ' | <a class="'.$this->itemd($tab,$post_type,'current',false).'" href="'.admin_url('admin.php').'?page='.$this->plugin_slug.'&tab='.$post_type.'">'.$label.'</a>'; |
|
361 | + echo '<div class="wet-navigation"><div class="subsubsub"><a class="'.$this->itemd($tab, '', 'current', false).'" href="'.admin_url('admin.php').'?page='.$this->plugin_slug.'">'.esc_attr('Home', 'wetu-importer').'</a>'; |
|
362 | + foreach ($post_types as $post_type => $label) { |
|
363 | + echo ' | <a class="'.$this->itemd($tab, $post_type, 'current', false).'" href="'.admin_url('admin.php').'?page='.$this->plugin_slug.'&tab='.$post_type.'">'.$label.'</a>'; |
|
364 | 364 | } |
365 | 365 | echo '</div><br clear="both"/></div>'; |
366 | 366 | } |
@@ -369,12 +369,12 @@ discard block |
||
369 | 369 | * Grabs the custom fields, and resaves an array of unique items. |
370 | 370 | */ |
371 | 371 | public function cleanup_posts() { |
372 | - if(!empty($this->cleanup_posts)){ |
|
373 | - foreach($this->cleanup_posts as $id => $key) { |
|
372 | + if (!empty($this->cleanup_posts)) { |
|
373 | + foreach ($this->cleanup_posts as $id => $key) { |
|
374 | 374 | $prev_items = get_post_meta($id, $key, false); |
375 | 375 | $new_items = array_unique($prev_items); |
376 | 376 | delete_post_meta($id, $key); |
377 | - foreach($new_items as $new_item) { |
|
377 | + foreach ($new_items as $new_item) { |
|
378 | 378 | add_post_meta($id, $key, $new_item, false); |
379 | 379 | } |
380 | 380 | } |
@@ -82,20 +82,20 @@ discard block |
||
82 | 82 | public function __construct() { |
83 | 83 | $this->set_variables(); |
84 | 84 | |
85 | - add_action( 'lsx_tour_importer_admin_tab_'.$this->tab_slug, array($this,'display_page') ); |
|
86 | - add_action('wp_ajax_lsx_tour_importer',array($this,'process_ajax_search')); |
|
87 | - add_action('wp_ajax_nopriv_lsx_tour_importer',array($this,'process_ajax_search')); |
|
85 | + add_action('lsx_tour_importer_admin_tab_'.$this->tab_slug, array($this, 'display_page')); |
|
86 | + add_action('wp_ajax_lsx_tour_importer', array($this, 'process_ajax_search')); |
|
87 | + add_action('wp_ajax_nopriv_lsx_tour_importer', array($this, 'process_ajax_search')); |
|
88 | 88 | |
89 | - add_action('wp_ajax_lsx_import_items',array($this,'process_ajax_import')); |
|
90 | - add_action('wp_ajax_nopriv_lsx_import_items',array($this,'process_ajax_import')); |
|
89 | + add_action('wp_ajax_lsx_import_items', array($this, 'process_ajax_import')); |
|
90 | + add_action('wp_ajax_nopriv_lsx_import_items', array($this, 'process_ajax_import')); |
|
91 | 91 | |
92 | - $temp_options = get_option('_lsx-to_settings',false); |
|
93 | - if(false !== $temp_options && isset($temp_options[$this->plugin_slug]) && !empty($temp_options[$this->plugin_slug])){ |
|
92 | + $temp_options = get_option('_lsx-to_settings', false); |
|
93 | + if (false !== $temp_options && isset($temp_options[$this->plugin_slug]) && !empty($temp_options[$this->plugin_slug])) { |
|
94 | 94 | $this->options = $temp_options[$this->plugin_slug]; |
95 | 95 | } |
96 | 96 | |
97 | - $tour_options = get_option('wetu_importer_tour_settings',false); |
|
98 | - if(false !== $tour_options){ |
|
97 | + $tour_options = get_option('wetu_importer_tour_settings', false); |
|
98 | + if (false !== $tour_options) { |
|
99 | 99 | $this->tour_options = $tour_options; |
100 | 100 | } |
101 | 101 | } |
@@ -107,11 +107,11 @@ discard block |
||
107 | 107 | { |
108 | 108 | parent::set_variables(); |
109 | 109 | |
110 | - if ( false !== $this->api_username && false !== $this->api_password ) { |
|
110 | + if (false !== $this->api_username && false !== $this->api_password) { |
|
111 | 111 | $this->url = 'https://wetu.com/API/Itinerary/'; |
112 | - $this->url_qs = 'username=' . $this->api_username . '&password=' . $this->api_password; |
|
113 | - } elseif ( false !== $this->api_key ) { |
|
114 | - $this->url = 'https://wetu.com/API/Itinerary/' . $this->api_key; |
|
112 | + $this->url_qs = 'username='.$this->api_username.'&password='.$this->api_password; |
|
113 | + } elseif (false !== $this->api_key) { |
|
114 | + $this->url = 'https://wetu.com/API/Itinerary/'.$this->api_key; |
|
115 | 115 | $this->url_qs = ''; |
116 | 116 | } |
117 | 117 | } |
@@ -131,8 +131,8 @@ discard block |
||
131 | 131 | <form method="get" action="" id="posts-filter"> |
132 | 132 | <input type="hidden" name="post_type" class="post_type" value="<?php echo $this->tab_slug; ?>" /> |
133 | 133 | |
134 | - <p><input class="button button-primary add" type="button" value="<?php _e('Add to List','wetu-importer'); ?>" /> |
|
135 | - <input class="button button-primary clear" type="button" value="<?php _e('Clear','wetu-importer'); ?>" /> |
|
134 | + <p><input class="button button-primary add" type="button" value="<?php _e('Add to List', 'wetu-importer'); ?>" /> |
|
135 | + <input class="button button-primary clear" type="button" value="<?php _e('Clear', 'wetu-importer'); ?>" /> |
|
136 | 136 | </p> |
137 | 137 | |
138 | 138 | <table class="wp-list-table widefat fixed posts"> |
@@ -141,11 +141,11 @@ discard block |
||
141 | 141 | <tbody id="the-list"> |
142 | 142 | <tr class="post-0 type-tour status-none" id="post-0"> |
143 | 143 | <th class="check-column" scope="row"> |
144 | - <label for="cb-select-0" class="screen-reader-text"><?php _e('Enter a title to search for and press enter','wetu-importer'); ?></label> |
|
144 | + <label for="cb-select-0" class="screen-reader-text"><?php _e('Enter a title to search for and press enter', 'wetu-importer'); ?></label> |
|
145 | 145 | </th> |
146 | 146 | <td class="post-title page-title column-title"> |
147 | 147 | <strong> |
148 | - <?php _e('Enter a title to search for','wetu-importer'); ?> |
|
148 | + <?php _e('Enter a title to search for', 'wetu-importer'); ?> |
|
149 | 149 | </strong> |
150 | 150 | </td> |
151 | 151 | <td class="date column-date"> |
@@ -159,8 +159,8 @@ discard block |
||
159 | 159 | |
160 | 160 | </table> |
161 | 161 | |
162 | - <p><input class="button button-primary add" type="button" value="<?php _e('Add to List','wetu-importer'); ?>" /> |
|
163 | - <input class="button button-primary clear" type="button" value="<?php _e('Clear','wetu-importer'); ?>" /> |
|
162 | + <p><input class="button button-primary add" type="button" value="<?php _e('Add to List', 'wetu-importer'); ?>" /> |
|
163 | + <input class="button button-primary clear" type="button" value="<?php _e('Clear', 'wetu-importer'); ?>" /> |
|
164 | 164 | </p> |
165 | 165 | </form> |
166 | 166 | |
@@ -172,16 +172,16 @@ discard block |
||
172 | 172 | <div class="settings-all" style="width:30%;display:block;float:left;"> |
173 | 173 | <h3><?php _e('What content to Sync from WETU'); ?></h3> |
174 | 174 | <ul> |
175 | - <li><input class="content select-all" <?php $this->checked($this->destination_options,'all'); ?> type="checkbox"name="content[]" value="all" /> <?php _e('Select All','wetu-importer'); ?></li> |
|
176 | - <li><input class="content" <?php $this->checked($this->tour_options,'description'); ?> type="checkbox" name="content[]" value="description" /> <?php _e('Description','wetu-importer'); ?></li> |
|
177 | - <li><input class="content" <?php $this->checked($this->tour_options,'excerpt'); ?> type="checkbox" name="content[]" value="excerpt" /> <?php _e('Excerpt','wetu-importer'); ?></li> |
|
175 | + <li><input class="content select-all" <?php $this->checked($this->destination_options, 'all'); ?> type="checkbox"name="content[]" value="all" /> <?php _e('Select All', 'wetu-importer'); ?></li> |
|
176 | + <li><input class="content" <?php $this->checked($this->tour_options, 'description'); ?> type="checkbox" name="content[]" value="description" /> <?php _e('Description', 'wetu-importer'); ?></li> |
|
177 | + <li><input class="content" <?php $this->checked($this->tour_options, 'excerpt'); ?> type="checkbox" name="content[]" value="excerpt" /> <?php _e('Excerpt', 'wetu-importer'); ?></li> |
|
178 | 178 | |
179 | - <li><input class="content" <?php $this->checked($this->tour_options,'price'); ?> type="checkbox" name="content[]" value="price" /> <?php _e('Price','wetu-importer'); ?></li> |
|
180 | - <li><input class="content" <?php $this->checked($this->tour_options,'duration'); ?> type="checkbox" name="content[]" value="duration" /> <?php _e('Duration','wetu-importer'); ?></li> |
|
179 | + <li><input class="content" <?php $this->checked($this->tour_options, 'price'); ?> type="checkbox" name="content[]" value="price" /> <?php _e('Price', 'wetu-importer'); ?></li> |
|
180 | + <li><input class="content" <?php $this->checked($this->tour_options, 'duration'); ?> type="checkbox" name="content[]" value="duration" /> <?php _e('Duration', 'wetu-importer'); ?></li> |
|
181 | 181 | |
182 | - <li><input class="content" <?php $this->checked($this->tour_options,'category'); ?> type="checkbox" name="content[]" value="category" /> <?php _e('Category','wetu-importer'); ?></li> |
|
182 | + <li><input class="content" <?php $this->checked($this->tour_options, 'category'); ?> type="checkbox" name="content[]" value="category" /> <?php _e('Category', 'wetu-importer'); ?></li> |
|
183 | 183 | |
184 | - <li><input class="content" <?php $this->checked($this->tour_options,'itineraries'); ?> type="checkbox" name="content[]" value="itineraries" /> <?php _e('Itinerary Days','wetu-importer'); ?></li> |
|
184 | + <li><input class="content" <?php $this->checked($this->tour_options, 'itineraries'); ?> type="checkbox" name="content[]" value="itineraries" /> <?php _e('Itinerary Days', 'wetu-importer'); ?></li> |
|
185 | 185 | |
186 | 186 | <?php /*if(class_exists('LSX_TO_Maps')){ ?> |
187 | 187 | <li><input class="content" <?php $this->checked($this->tour_options,'map'); ?> type="checkbox" name="content[]" value="map" /> <?php _e('Map Coordinates (generates a KML file)','wetu-importer'); ?></li> |
@@ -191,18 +191,18 @@ discard block |
||
191 | 191 | <div class="settings-all" style="width:30%;display:block;float:left;"> |
192 | 192 | <h3><?php _e('Itinerary Info'); ?></h3> |
193 | 193 | <ul> |
194 | - <li><input class="content" <?php $this->checked($this->tour_options,'itinerary_description'); ?> type="checkbox" name="content[]" value="itinerary_description" /> <?php _e('Description','wetu-importer'); ?></li> |
|
195 | - <li><input class="content" <?php $this->checked($this->tour_options,'itinerary_included'); ?> type="checkbox" name="content[]" value="itinerary_included" /> <?php _e('Included','wetu-importer'); ?></li> |
|
196 | - <li><input class="content" <?php $this->checked($this->tour_options,'itinerary_excluded'); ?> type="checkbox" name="content[]" value="itinerary_excluded" /> <?php _e('Excluded','wetu-importer'); ?></li> |
|
194 | + <li><input class="content" <?php $this->checked($this->tour_options, 'itinerary_description'); ?> type="checkbox" name="content[]" value="itinerary_description" /> <?php _e('Description', 'wetu-importer'); ?></li> |
|
195 | + <li><input class="content" <?php $this->checked($this->tour_options, 'itinerary_included'); ?> type="checkbox" name="content[]" value="itinerary_included" /> <?php _e('Included', 'wetu-importer'); ?></li> |
|
196 | + <li><input class="content" <?php $this->checked($this->tour_options, 'itinerary_excluded'); ?> type="checkbox" name="content[]" value="itinerary_excluded" /> <?php _e('Excluded', 'wetu-importer'); ?></li> |
|
197 | 197 | </ul> |
198 | 198 | |
199 | 199 | <h4><?php _e('Additional Content'); ?></h4> |
200 | 200 | <ul> |
201 | - <li><input class="content" <?php $this->checked($this->tour_options,'accommodation'); ?> type="checkbox" name="content[]" value="accommodation" /> <?php _e('Sync Accommodation','wetu-importer'); ?></li> |
|
202 | - <li><input class="content" <?php $this->checked($this->tour_options,'destination'); ?> type="checkbox" name="content[]" value="destination" /> <?php _e('Sync Destinations','wetu-importer'); ?></li> |
|
201 | + <li><input class="content" <?php $this->checked($this->tour_options, 'accommodation'); ?> type="checkbox" name="content[]" value="accommodation" /> <?php _e('Sync Accommodation', 'wetu-importer'); ?></li> |
|
202 | + <li><input class="content" <?php $this->checked($this->tour_options, 'destination'); ?> type="checkbox" name="content[]" value="destination" /> <?php _e('Sync Destinations', 'wetu-importer'); ?></li> |
|
203 | 203 | </ul> |
204 | 204 | </div> |
205 | - <?php if(class_exists('LSX_TO_Team')){ ?> |
|
205 | + <?php if (class_exists('LSX_TO_Team')) { ?> |
|
206 | 206 | <div style="width:30%;display:block;float:left;"> |
207 | 207 | <h3><?php _e('Assign a Team Member'); ?></h3> |
208 | 208 | <?php $this->team_member_checkboxes($this->tour_options); ?> |
@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | |
215 | 215 | |
216 | 216 | <h3><?php _e('Your List'); ?></h3> |
217 | - <p><input class="button button-primary" type="submit" value="<?php _e('Sync','wetu-importer'); ?>" /></p> |
|
217 | + <p><input class="button button-primary" type="submit" value="<?php _e('Sync', 'wetu-importer'); ?>" /></p> |
|
218 | 218 | <table class="wp-list-table widefat fixed posts"> |
219 | 219 | <?php $this->table_header(); ?> |
220 | 220 | |
@@ -226,12 +226,12 @@ discard block |
||
226 | 226 | |
227 | 227 | </table> |
228 | 228 | |
229 | - <p><input class="button button-primary" type="submit" value="<?php _e('Sync','wetu-importer'); ?>" /></p> |
|
229 | + <p><input class="button button-primary" type="submit" value="<?php _e('Sync', 'wetu-importer'); ?>" /></p> |
|
230 | 230 | </form> |
231 | 231 | </div> |
232 | 232 | |
233 | 233 | <div style="display:none;" class="completed-list-wrapper"> |
234 | - <h3><?php _e('Completed','wetu-importer'); ?> - <small><?php _e('Import your','wetu-importer'); ?> <a href="<?php echo admin_url('admin.php'); ?>?page=<?php echo $this->plugin_slug; ?>&tab=accommodation"><?php _e('accommodation'); ?></a> <?php _e('next','wetu-importer'); ?></small></h3> |
|
234 | + <h3><?php _e('Completed', 'wetu-importer'); ?> - <small><?php _e('Import your', 'wetu-importer'); ?> <a href="<?php echo admin_url('admin.php'); ?>?page=<?php echo $this->plugin_slug; ?>&tab=accommodation"><?php _e('accommodation'); ?></a> <?php _e('next', 'wetu-importer'); ?></small></h3> |
|
235 | 235 | <ul> |
236 | 236 | </ul> |
237 | 237 | </div> |
@@ -244,20 +244,20 @@ discard block |
||
244 | 244 | */ |
245 | 245 | public function update_options_form() { |
246 | 246 | $tours = get_transient('lsx_ti_tours'); |
247 | - echo '<div class="wetu-status"><h3>'.__('Wetu Status','wetu-importer').' - '; |
|
248 | - if('' === $tours || false === $tours || isset($_GET['refresh_tours'])){ |
|
247 | + echo '<div class="wetu-status"><h3>'.__('Wetu Status', 'wetu-importer').' - '; |
|
248 | + if ('' === $tours || false === $tours || isset($_GET['refresh_tours'])) { |
|
249 | 249 | $result = $this->update_options(); |
250 | 250 | |
251 | - if(true === $result){ |
|
252 | - echo '<span style="color:green;">'.esc_attr('Connected','wetu-importer').'</span>'; |
|
253 | - if(!isset($_GET['refresh_tours'])){ |
|
254 | - echo ' - <small><a href="'.admin_url('admin.php').'?page='.$this->plugin_slug.'&tab=tour&refresh_tours=true">'.esc_attr('Refresh','wetu-importer').'</a></small>'; |
|
251 | + if (true === $result) { |
|
252 | + echo '<span style="color:green;">'.esc_attr('Connected', 'wetu-importer').'</span>'; |
|
253 | + if (!isset($_GET['refresh_tours'])) { |
|
254 | + echo ' - <small><a href="'.admin_url('admin.php').'?page='.$this->plugin_slug.'&tab=tour&refresh_tours=true">'.esc_attr('Refresh', 'wetu-importer').'</a></small>'; |
|
255 | 255 | } |
256 | - }else{ |
|
256 | + }else { |
|
257 | 257 | echo '<span style="color:red;">'.wp_kses_post($result).'</span>'; |
258 | 258 | } |
259 | - }else{ |
|
260 | - echo '<span style="color:green;">'.esc_attr('Connected','wetu-importer').'</span> - <small><a href="'.admin_url('admin.php').'?page='.$this->plugin_slug.'&tab=tour&refresh_tours=true">'.esc_attr('Refresh','wetu-importer').'</a></small>'; |
|
259 | + }else { |
|
260 | + echo '<span style="color:green;">'.esc_attr('Connected', 'wetu-importer').'</span> - <small><a href="'.admin_url('admin.php').'?page='.$this->plugin_slug.'&tab=tour&refresh_tours=true">'.esc_attr('Refresh', 'wetu-importer').'</a></small>'; |
|
261 | 261 | } |
262 | 262 | echo '</h3></div>'; |
263 | 263 | } |
@@ -266,13 +266,13 @@ discard block |
||
266 | 266 | * Save the list of Tours into an option |
267 | 267 | */ |
268 | 268 | public function update_options() { |
269 | - $data = file_get_contents( $this->url . '/V7/List?' . $this->url_qs . '&own=true&type=All' ); |
|
269 | + $data = file_get_contents($this->url.'/V7/List?'.$this->url_qs.'&own=true&type=All'); |
|
270 | 270 | $tours = json_decode($data, true); |
271 | 271 | |
272 | - if(isset($tours['error'])){ |
|
272 | + if (isset($tours['error'])) { |
|
273 | 273 | return $tours['error']; |
274 | 274 | }elseif (isset($tours['itineraries']) && !empty($tours['itineraries'])) { |
275 | - set_transient('lsx_ti_tours',$tours['itineraries'],60*60*2); |
|
275 | + set_transient('lsx_ti_tours', $tours['itineraries'], 60 * 60 * 2); |
|
276 | 276 | return true; |
277 | 277 | } |
278 | 278 | } |
@@ -296,8 +296,8 @@ discard block |
||
296 | 296 | |
297 | 297 | LIMIT 0,500 |
298 | 298 | "); |
299 | - if(null !== $current_tours && !empty($current_tours)){ |
|
300 | - foreach($current_tours as $tour){ |
|
299 | + if (null !== $current_tours && !empty($current_tours)) { |
|
300 | + foreach ($current_tours as $tour) { |
|
301 | 301 | $return[$tour->meta_value] = $tour; |
302 | 302 | } |
303 | 303 | } |
@@ -310,36 +310,36 @@ discard block |
||
310 | 310 | public function process_ajax_search() { |
311 | 311 | $return = false; |
312 | 312 | |
313 | - if(isset($_POST['action']) && $_POST['action'] === 'lsx_tour_importer' && isset($_POST['type']) && $_POST['type'] === $this->tab_slug){ |
|
313 | + if (isset($_POST['action']) && $_POST['action'] === 'lsx_tour_importer' && isset($_POST['type']) && $_POST['type'] === $this->tab_slug) { |
|
314 | 314 | $tours = get_transient('lsx_ti_tours'); |
315 | - if ( false !== $tours) { |
|
315 | + if (false !== $tours) { |
|
316 | 316 | |
317 | 317 | $searched_items = false; |
318 | 318 | |
319 | - if(isset($_POST['keyword'] )) { |
|
319 | + if (isset($_POST['keyword'])) { |
|
320 | 320 | $keyphrases = $_POST['keyword']; |
321 | - }else{ |
|
321 | + }else { |
|
322 | 322 | $keyphrases = array(0); |
323 | 323 | } |
324 | 324 | |
325 | - if(!is_array($keyphrases)){ |
|
325 | + if (!is_array($keyphrases)) { |
|
326 | 326 | $keyphrases = array($keyphrases); |
327 | 327 | } |
328 | - foreach($keyphrases as &$keyword){ |
|
328 | + foreach ($keyphrases as &$keyword) { |
|
329 | 329 | $keyword = ltrim(rtrim($keyword)); |
330 | 330 | } |
331 | 331 | |
332 | 332 | $post_status = false; |
333 | - if(in_array('publish',$keyphrases)){ |
|
333 | + if (in_array('publish', $keyphrases)) { |
|
334 | 334 | $post_status = 'publish'; |
335 | 335 | } |
336 | - if(in_array('pending',$keyphrases)){ |
|
336 | + if (in_array('pending', $keyphrases)) { |
|
337 | 337 | $post_status = 'pending'; |
338 | 338 | } |
339 | - if(in_array('draft',$keyphrases)){ |
|
339 | + if (in_array('draft', $keyphrases)) { |
|
340 | 340 | $post_status = 'draft'; |
341 | 341 | } |
342 | - if(in_array('import',$keyphrases)){ |
|
342 | + if (in_array('import', $keyphrases)) { |
|
343 | 343 | $post_status = 'import'; |
344 | 344 | } |
345 | 345 | |
@@ -347,9 +347,9 @@ discard block |
||
347 | 347 | if (!empty($tours)) { |
348 | 348 | $current_tours = $this->find_current_tours(); |
349 | 349 | |
350 | - foreach($tours as $row_key => $row){ |
|
350 | + foreach ($tours as $row_key => $row) { |
|
351 | 351 | |
352 | - if(isset($row['is_disabled']) && true === $row['is_disabled']){ |
|
352 | + if (isset($row['is_disabled']) && true === $row['is_disabled']) { |
|
353 | 353 | continue; |
354 | 354 | } |
355 | 355 | |
@@ -359,29 +359,29 @@ discard block |
||
359 | 359 | |
360 | 360 | //If this is a current tour, add its ID to the row. |
361 | 361 | $row['post_id'] = 0; |
362 | - if(false !== $current_tours && array_key_exists($row['identifier'], $current_tours)){ |
|
362 | + if (false !== $current_tours && array_key_exists($row['identifier'], $current_tours)) { |
|
363 | 363 | $row['post_id'] = $current_tours[$row['identifier']]->post_id; |
364 | 364 | } |
365 | 365 | |
366 | 366 | //If we are searching for |
367 | - if(false !== $post_status){ |
|
367 | + if (false !== $post_status) { |
|
368 | 368 | |
369 | - if('import' === $post_status){ |
|
369 | + if ('import' === $post_status) { |
|
370 | 370 | |
371 | - if(0 !== $row['post_id']){ |
|
371 | + if (0 !== $row['post_id']) { |
|
372 | 372 | continue; |
373 | - }else{ |
|
373 | + }else { |
|
374 | 374 | $searched_items[sanitize_title($row['name']).'-'.$row['identifier']] = $this->format_row($row); |
375 | 375 | } |
376 | 376 | |
377 | 377 | |
378 | - }else{ |
|
378 | + }else { |
|
379 | 379 | |
380 | - if(0 === $row['post_id']){ |
|
380 | + if (0 === $row['post_id']) { |
|
381 | 381 | continue; |
382 | - }else{ |
|
382 | + }else { |
|
383 | 383 | $current_status = get_post_status($row['post_id']); |
384 | - if($current_status !== $post_status){ |
|
384 | + if ($current_status !== $post_status) { |
|
385 | 385 | continue; |
386 | 386 | } |
387 | 387 | |
@@ -390,17 +390,17 @@ discard block |
||
390 | 390 | |
391 | 391 | } |
392 | 392 | |
393 | - }else{ |
|
393 | + }else { |
|
394 | 394 | //Search through each keyword. |
395 | - foreach($keyphrases as $keyphrase){ |
|
395 | + foreach ($keyphrases as $keyphrase) { |
|
396 | 396 | |
397 | 397 | //Make sure the keyphrase is turned into an array |
398 | - $keywords = explode(" ",$keyphrase); |
|
399 | - if(!is_array($keywords)){ |
|
398 | + $keywords = explode(" ", $keyphrase); |
|
399 | + if (!is_array($keywords)) { |
|
400 | 400 | $keywords = array($keywords); |
401 | 401 | } |
402 | 402 | |
403 | - if($this->multineedle_stripos(ltrim(rtrim($row['name'])), $keywords) !== false){ |
|
403 | + if ($this->multineedle_stripos(ltrim(rtrim($row['name'])), $keywords) !== false) { |
|
404 | 404 | $searched_items[sanitize_title($row['name']).'-'.$row['identifier']] = $this->format_row($row); |
405 | 405 | } |
406 | 406 | } |
@@ -408,7 +408,7 @@ discard block |
||
408 | 408 | } |
409 | 409 | } |
410 | 410 | |
411 | - if(false !== $searched_items){ |
|
411 | + if (false !== $searched_items) { |
|
412 | 412 | ksort($searched_items); |
413 | 413 | $return = implode($searched_items); |
414 | 414 | } |
@@ -421,11 +421,11 @@ discard block |
||
421 | 421 | /** |
422 | 422 | * Formats the row for output on the screen. |
423 | 423 | */ |
424 | - public function format_row($row = false){ |
|
425 | - if(false !== $row){ |
|
424 | + public function format_row($row = false) { |
|
425 | + if (false !== $row) { |
|
426 | 426 | |
427 | 427 | $status = 'import'; |
428 | - if(0 !== $row['post_id']){ |
|
428 | + if (0 !== $row['post_id']) { |
|
429 | 429 | $status = '<a href="'.admin_url('/post.php?post='.$row['post_id'].'&action=edit').'" target="_blank">'.get_post_status($row['post_id']).'</a>'; |
430 | 430 | } |
431 | 431 | |
@@ -439,7 +439,7 @@ discard block |
||
439 | 439 | <strong>'.$row['name'].'</strong> - '.$status.' |
440 | 440 | </td> |
441 | 441 | <td class="date column-date"> |
442 | - <abbr title="'.date('Y/m/d',strtotime($row['last_modified'])).'">'.date('Y/m/d',strtotime($row['last_modified'])).'</abbr><br>Last Modified |
|
442 | + <abbr title="'.date('Y/m/d', strtotime($row['last_modified'])).'">'.date('Y/m/d', strtotime($row['last_modified'])).'</abbr><br>Last Modified |
|
443 | 443 | </td> |
444 | 444 | <td class="ssid column-ssid"> |
445 | 445 | '.$row['identifier'].' |
@@ -454,31 +454,31 @@ discard block |
||
454 | 454 | */ |
455 | 455 | public function process_ajax_import($force = false) { |
456 | 456 | $return = false; |
457 | - if(isset($_POST['action']) && $_POST['action'] === 'lsx_import_items' && isset($_POST['type']) && $_POST['type'] === $this->tab_slug && isset($_POST['wetu_id'])){ |
|
457 | + if (isset($_POST['action']) && $_POST['action'] === 'lsx_import_items' && isset($_POST['type']) && $_POST['type'] === $this->tab_slug && isset($_POST['wetu_id'])) { |
|
458 | 458 | |
459 | 459 | $wetu_id = $_POST['wetu_id']; |
460 | - if(isset($_POST['post_id'])){ |
|
460 | + if (isset($_POST['post_id'])) { |
|
461 | 461 | $post_id = $_POST['post_id']; |
462 | - }else{ |
|
462 | + }else { |
|
463 | 463 | $post_id = 0; |
464 | 464 | } |
465 | 465 | |
466 | - if(isset($_POST['content']) && is_array($_POST['content']) && !empty($_POST['content'])){ |
|
466 | + if (isset($_POST['content']) && is_array($_POST['content']) && !empty($_POST['content'])) { |
|
467 | 467 | $content = $_POST['content']; |
468 | - add_option('wetu_importer_tour_settings',$content); |
|
469 | - }else{ |
|
468 | + add_option('wetu_importer_tour_settings', $content); |
|
469 | + }else { |
|
470 | 470 | delete_option('wetu_importer_tour_settings'); |
471 | 471 | $content = false; |
472 | 472 | } |
473 | 473 | |
474 | - $jdata=file_get_contents("http://wetu.com/API/Itinerary/V7/Get?id=".$wetu_id); |
|
474 | + $jdata = file_get_contents("http://wetu.com/API/Itinerary/V7/Get?id=".$wetu_id); |
|
475 | 475 | |
476 | - if($jdata) |
|
476 | + if ($jdata) |
|
477 | 477 | { |
478 | - $jdata=json_decode($jdata,true); |
|
479 | - if(!empty($jdata)) |
|
478 | + $jdata = json_decode($jdata, true); |
|
479 | + if (!empty($jdata)) |
|
480 | 480 | { |
481 | - $return = $this->import_row($jdata,$wetu_id,$post_id,$content); |
|
481 | + $return = $this->import_row($jdata, $wetu_id, $post_id, $content); |
|
482 | 482 | $this->format_completed_row($return); |
483 | 483 | $this->cleanup_posts(); |
484 | 484 | } |
@@ -494,7 +494,7 @@ discard block |
||
494 | 494 | * @param $data array |
495 | 495 | * @param $wetu_id string |
496 | 496 | */ |
497 | - public function import_row($data,$wetu_id,$id=0,$importable_content=false,$old1=false,$old2=false) { |
|
497 | + public function import_row($data, $wetu_id, $id = 0, $importable_content = false, $old1 = false, $old2 = false) { |
|
498 | 498 | $post_name = $data_post_content = $data_post_excerpt = ''; |
499 | 499 | $post = array( |
500 | 500 | 'post_type' => 'tour', |
@@ -502,29 +502,29 @@ discard block |
||
502 | 502 | |
503 | 503 | //Set the post_content |
504 | 504 | $content_used_general_description = false; |
505 | - if(false !== $importable_content && in_array('description',$importable_content)){ |
|
505 | + if (false !== $importable_content && in_array('description', $importable_content)) { |
|
506 | 506 | $data_post_content = ''; |
507 | 507 | |
508 | - if(isset($data['description'])){ |
|
508 | + if (isset($data['description'])) { |
|
509 | 509 | $data_post_content = $data['description']; |
510 | - }elseif(isset($data['summary'])){ |
|
510 | + }elseif (isset($data['summary'])) { |
|
511 | 511 | $data_post_content = $data['summary']; |
512 | 512 | } |
513 | 513 | $post['post_content'] = $data_post_content; |
514 | 514 | } |
515 | 515 | |
516 | 516 | //Create or update the post |
517 | - if(false !== $id && '0' !== $id){ |
|
517 | + if (false !== $id && '0' !== $id) { |
|
518 | 518 | $post['ID'] = $id; |
519 | 519 | $post['post_status'] = 'publish'; |
520 | 520 | $id = wp_update_post($post); |
521 | - $prev_date = get_post_meta($id,'lsx_wetu_modified_date',true); |
|
522 | - update_post_meta($id,'lsx_wetu_modified_date',strtotime($data['last_modified']),$prev_date); |
|
523 | - }else{ |
|
521 | + $prev_date = get_post_meta($id, 'lsx_wetu_modified_date', true); |
|
522 | + update_post_meta($id, 'lsx_wetu_modified_date', strtotime($data['last_modified']), $prev_date); |
|
523 | + }else { |
|
524 | 524 | |
525 | 525 | //Set the name |
526 | - if(isset($data['name'])){ |
|
527 | - $post_name = wp_unique_post_slug(sanitize_title($data['name']),$id, 'draft', 'tour', 0); |
|
526 | + if (isset($data['name'])) { |
|
527 | + $post_name = wp_unique_post_slug(sanitize_title($data['name']), $id, 'draft', 'tour', 0); |
|
528 | 528 | } |
529 | 529 | $post['post_name'] = $post_name; |
530 | 530 | $post['post_title'] = $data['name']; |
@@ -532,51 +532,51 @@ discard block |
||
532 | 532 | $id = wp_insert_post($post); |
533 | 533 | |
534 | 534 | //Save the WETU ID and the Last date it was modified. |
535 | - if(false !== $id){ |
|
536 | - add_post_meta($id,'lsx_wetu_id',$wetu_id); |
|
537 | - add_post_meta($id,'lsx_wetu_modified_date',strtotime($data['last_modified'])); |
|
535 | + if (false !== $id) { |
|
536 | + add_post_meta($id, 'lsx_wetu_id', $wetu_id); |
|
537 | + add_post_meta($id, 'lsx_wetu_modified_date', strtotime($data['last_modified'])); |
|
538 | 538 | } |
539 | 539 | } |
540 | 540 | |
541 | 541 | |
542 | 542 | //Set the price |
543 | - if(false !== $importable_content && in_array('price',$importable_content)){ |
|
544 | - $this->set_price($data,$id); |
|
543 | + if (false !== $importable_content && in_array('price', $importable_content)) { |
|
544 | + $this->set_price($data, $id); |
|
545 | 545 | } |
546 | 546 | |
547 | 547 | //Set the Duration |
548 | - if(false !== $importable_content && in_array('duration',$importable_content)){ |
|
549 | - $this->set_duration($data,$id); |
|
548 | + if (false !== $importable_content && in_array('duration', $importable_content)) { |
|
549 | + $this->set_duration($data, $id); |
|
550 | 550 | } |
551 | 551 | |
552 | - if(in_array('itineraries',$importable_content) && isset($data['legs']) && !empty($data['legs'])){ |
|
553 | - $this->process_itineraries($data,$id,$importable_content); |
|
552 | + if (in_array('itineraries', $importable_content) && isset($data['legs']) && !empty($data['legs'])) { |
|
553 | + $this->process_itineraries($data, $id, $importable_content); |
|
554 | 554 | } |
555 | 555 | |
556 | - if(in_array('map',$importable_content) && isset($data['routes']) && !empty($data['routes'])){ |
|
557 | - $this->process_map_points($data,$id); |
|
556 | + if (in_array('map', $importable_content) && isset($data['routes']) && !empty($data['routes'])) { |
|
557 | + $this->process_map_points($data, $id); |
|
558 | 558 | } |
559 | 559 | |
560 | 560 | //TODO Test These |
561 | 561 | //Setup some default for use in the import |
562 | - if(false !== $importable_content && (in_array('itinerary_gallery',$importable_content) || in_array('gallery',$importable_content) || in_array('banner_image',$importable_content) || in_array('featured_image',$importable_content))){ |
|
562 | + if (false !== $importable_content && (in_array('itinerary_gallery', $importable_content) || in_array('gallery', $importable_content) || in_array('banner_image', $importable_content) || in_array('featured_image', $importable_content))) { |
|
563 | 563 | $this->find_attachments($id); |
564 | 564 | } |
565 | 565 | //Set the featured image |
566 | 566 | //TODO Test These |
567 | - if(false !== $importable_content && in_array('featured_image',$importable_content)){ |
|
568 | - $this->set_featured_image($data,$id); |
|
567 | + if (false !== $importable_content && in_array('featured_image', $importable_content)) { |
|
568 | + $this->set_featured_image($data, $id); |
|
569 | 569 | } |
570 | 570 | |
571 | 571 | //TODO Test These |
572 | - if(false !== $importable_content && in_array('banner_image',$importable_content)){ |
|
573 | - $this->set_banner_image($data,$id); |
|
572 | + if (false !== $importable_content && in_array('banner_image', $importable_content)) { |
|
573 | + $this->set_banner_image($data, $id); |
|
574 | 574 | } |
575 | 575 | |
576 | 576 | //TODO Test These |
577 | 577 | //Import the main gallery |
578 | - if(false !== $importable_content && in_array('gallery',$importable_content)){ |
|
579 | - $this->create_main_gallery($data,$id); |
|
578 | + if (false !== $importable_content && in_array('gallery', $importable_content)) { |
|
579 | + $this->create_main_gallery($data, $id); |
|
580 | 580 | } |
581 | 581 | |
582 | 582 | return $id; |
@@ -585,151 +585,151 @@ discard block |
||
585 | 585 | /** |
586 | 586 | * A loop which runs through each leg on the tour. |
587 | 587 | */ |
588 | - public function process_itineraries($data,$id,$importable_content) { |
|
588 | + public function process_itineraries($data, $id, $importable_content) { |
|
589 | 589 | $day_counter = 1; |
590 | 590 | $leg_counter = 0; |
591 | 591 | |
592 | - delete_post_meta($id,'itinerary'); |
|
592 | + delete_post_meta($id, 'itinerary'); |
|
593 | 593 | |
594 | - if(false !== $importable_content && in_array('accommodation',$importable_content)){ |
|
595 | - delete_post_meta($id,'accommodation_to_tour'); |
|
594 | + if (false !== $importable_content && in_array('accommodation', $importable_content)) { |
|
595 | + delete_post_meta($id, 'accommodation_to_tour'); |
|
596 | 596 | } |
597 | - if(false !== $importable_content && in_array('destination',$importable_content)){ |
|
598 | - delete_post_meta($id,'destination_to_tour'); |
|
599 | - delete_post_meta($id,'departs_from'); |
|
600 | - delete_post_meta($id,'ends_in'); |
|
597 | + if (false !== $importable_content && in_array('destination', $importable_content)) { |
|
598 | + delete_post_meta($id, 'destination_to_tour'); |
|
599 | + delete_post_meta($id, 'departs_from'); |
|
600 | + delete_post_meta($id, 'ends_in'); |
|
601 | 601 | } |
602 | 602 | |
603 | 603 | $departs_from = false; |
604 | 604 | $ends_in = false; |
605 | 605 | |
606 | - foreach($data['legs'] as $leg){ |
|
606 | + foreach ($data['legs'] as $leg) { |
|
607 | 607 | |
608 | - if(isset($leg['days']) && !empty($leg['days'])){ |
|
608 | + if (isset($leg['days']) && !empty($leg['days'])) { |
|
609 | 609 | |
610 | 610 | //Itinerary Accommodation |
611 | 611 | $current_accommodation = false; |
612 | - if(false !== $importable_content && in_array('accommodation',$importable_content)){ |
|
613 | - $current_accommodation = $this->set_accommodation($leg,$id); |
|
612 | + if (false !== $importable_content && in_array('accommodation', $importable_content)) { |
|
613 | + $current_accommodation = $this->set_accommodation($leg, $id); |
|
614 | 614 | } |
615 | 615 | |
616 | 616 | //Itinerary Destination |
617 | 617 | $current_destination = false; |
618 | - if(false !== $importable_content && in_array('destination',$importable_content)){ |
|
619 | - $current_destination = $this->set_destination($leg,$id); |
|
618 | + if (false !== $importable_content && in_array('destination', $importable_content)) { |
|
619 | + $current_destination = $this->set_destination($leg, $id); |
|
620 | 620 | } |
621 | 621 | |
622 | 622 | //If the Nights are the same mount of days in the array, then it isnt "By Destination" |
623 | - if($leg['nights'] === count($leg['days']) || 0 === $leg['itinerary_leg_id']){ |
|
623 | + if ($leg['nights'] === count($leg['days']) || 0 === $leg['itinerary_leg_id']) { |
|
624 | 624 | |
625 | - foreach($leg['days'] as $day){ |
|
625 | + foreach ($leg['days'] as $day) { |
|
626 | 626 | |
627 | 627 | $current_day = array(); |
628 | 628 | |
629 | - $current_day['title'] = esc_attr('Day ','wetu-importer').$day_counter; |
|
629 | + $current_day['title'] = esc_attr('Day ', 'wetu-importer').$day_counter; |
|
630 | 630 | |
631 | 631 | //print_r('<pre>');print_r($day['notes']);print_r('</pre>'); |
632 | 632 | |
633 | 633 | //Description |
634 | - if(false !== $importable_content && in_array('itinerary_description',$importable_content) && isset($day['notes'])){ |
|
634 | + if (false !== $importable_content && in_array('itinerary_description', $importable_content) && isset($day['notes'])) { |
|
635 | 635 | $current_day['description'] = $day['notes']; |
636 | - }else{ |
|
636 | + }else { |
|
637 | 637 | $current_day['description'] = ''; |
638 | 638 | } |
639 | 639 | |
640 | 640 | //Itinerary Gallery |
641 | - if(false !== $importable_content && in_array('itinerary_gallery',$importable_content) && isset($day['images'])){ |
|
641 | + if (false !== $importable_content && in_array('itinerary_gallery', $importable_content) && isset($day['images'])) { |
|
642 | 642 | $current_day['featured_image'] = ''; |
643 | - }else{ |
|
643 | + }else { |
|
644 | 644 | $current_day['featured_image'] = ''; |
645 | 645 | } |
646 | 646 | |
647 | 647 | //Accommodation |
648 | - if(false !== $current_accommodation){ |
|
648 | + if (false !== $current_accommodation) { |
|
649 | 649 | $current_day['accommodation_to_tour'] = array($current_accommodation); |
650 | - }else{ |
|
650 | + }else { |
|
651 | 651 | $current_day['accommodation_to_tour'] = array(); |
652 | 652 | } |
653 | 653 | |
654 | 654 | //Destination |
655 | - if(false !== $current_destination){ |
|
655 | + if (false !== $current_destination) { |
|
656 | 656 | $current_day['destination_to_tour'] = array($current_destination); |
657 | - }else{ |
|
657 | + }else { |
|
658 | 658 | $current_day['destination_to_tour'] = array(); |
659 | 659 | } |
660 | 660 | |
661 | 661 | //Included |
662 | - if(false !== $importable_content && in_array('itinerary_included',$importable_content) && isset($day['included']) && '' !== $day['included']){ |
|
662 | + if (false !== $importable_content && in_array('itinerary_included', $importable_content) && isset($day['included']) && '' !== $day['included']) { |
|
663 | 663 | $current_day['included'] = $day['included']; |
664 | - }else{ |
|
664 | + }else { |
|
665 | 665 | $current_day['included'] = ''; |
666 | 666 | } |
667 | 667 | |
668 | 668 | //Excluded |
669 | - if(false !== $importable_content && in_array('itinerary_excluded',$importable_content) && isset($day['excluded']) && '' !== $day['excluded']){ |
|
669 | + if (false !== $importable_content && in_array('itinerary_excluded', $importable_content) && isset($day['excluded']) && '' !== $day['excluded']) { |
|
670 | 670 | $current_day['excluded'] = $day['excluded']; |
671 | - }else{ |
|
671 | + }else { |
|
672 | 672 | $current_day['excluded'] = ''; |
673 | 673 | } |
674 | 674 | |
675 | - $this->set_itinerary_day($current_day,$id); |
|
675 | + $this->set_itinerary_day($current_day, $id); |
|
676 | 676 | $day_counter++; |
677 | 677 | } |
678 | 678 | |
679 | - }else{ |
|
680 | - $day_counter = $day_counter + (int)$leg['nights']; |
|
679 | + }else { |
|
680 | + $day_counter = $day_counter + (int) $leg['nights']; |
|
681 | 681 | } |
682 | 682 | |
683 | 683 | } |
684 | 684 | |
685 | 685 | //If we are in the first leg, and the destination was attached then save it as the departure field. |
686 | - if( 0 === $leg_counter && false !== $current_destination){ |
|
686 | + if (0 === $leg_counter && false !== $current_destination) { |
|
687 | 687 | $departs_from = $current_destination; |
688 | 688 | } |
689 | 689 | |
690 | 690 | //If its the last leg then save it as the ends in. |
691 | - if( $leg_counter === (count($data['legs'])-2) && false !== $current_destination){ |
|
691 | + if ($leg_counter === (count($data['legs']) - 2) && false !== $current_destination) { |
|
692 | 692 | $ends_in = $current_destination; |
693 | 693 | } |
694 | 694 | $leg_counter++; |
695 | 695 | } |
696 | 696 | |
697 | - if(false !== $departs_from){ |
|
698 | - add_post_meta($id,'departs_from',$departs_from,true); |
|
697 | + if (false !== $departs_from) { |
|
698 | + add_post_meta($id, 'departs_from', $departs_from, true); |
|
699 | 699 | } |
700 | - if(false !== $ends_in){ |
|
701 | - add_post_meta($id,'ends_in',$ends_in,true); |
|
700 | + if (false !== $ends_in) { |
|
701 | + add_post_meta($id, 'ends_in', $ends_in, true); |
|
702 | 702 | } |
703 | 703 | } |
704 | 704 | |
705 | 705 | /** |
706 | 706 | * Run through your routes and save the points as a KML file. |
707 | 707 | */ |
708 | - public function process_map_points($data,$id) { |
|
708 | + public function process_map_points($data, $id) { |
|
709 | 709 | |
710 | - if(!empty($data['routes'])){ |
|
710 | + if (!empty($data['routes'])) { |
|
711 | 711 | |
712 | - delete_post_meta($id,'wetu_map_points'); |
|
712 | + delete_post_meta($id, 'wetu_map_points'); |
|
713 | 713 | |
714 | 714 | $points = array(); |
715 | 715 | |
716 | - foreach($data['routes'] as $route){ |
|
716 | + foreach ($data['routes'] as $route) { |
|
717 | 717 | |
718 | 718 | |
719 | - if(isset($route['points']) && '' !== $route['points']){ |
|
719 | + if (isset($route['points']) && '' !== $route['points']) { |
|
720 | 720 | |
721 | - $temp_points = explode(';',$route['points']); |
|
721 | + $temp_points = explode(';', $route['points']); |
|
722 | 722 | $point_counter = count($temp_points); |
723 | 723 | |
724 | 724 | for ($x = 0; $x <= $point_counter; $x++) { |
725 | - $y = $x+1; |
|
725 | + $y = $x + 1; |
|
726 | 726 | $points[] = $temp_points[$x].','.$temp_points[$y]; |
727 | 727 | $x++; |
728 | 728 | } |
729 | 729 | } |
730 | 730 | } |
731 | - if(!empty($points)){ |
|
732 | - $this->save_custom_field(implode(' ',$points),'wetu_map_points',$id,false,true); |
|
731 | + if (!empty($points)) { |
|
732 | + $this->save_custom_field(implode(' ', $points), 'wetu_map_points', $id, false, true); |
|
733 | 733 | } |
734 | 734 | } |
735 | 735 | |
@@ -738,28 +738,28 @@ discard block |
||
738 | 738 | /** |
739 | 739 | * Set the Itinerary Day |
740 | 740 | */ |
741 | - public function set_itinerary_day($day,$id) { |
|
742 | - $this->save_custom_field($day,'itinerary',$id,false,false); |
|
741 | + public function set_itinerary_day($day, $id) { |
|
742 | + $this->save_custom_field($day, 'itinerary', $id, false, false); |
|
743 | 743 | } |
744 | 744 | |
745 | 745 | /** |
746 | 746 | * Set the price |
747 | 747 | */ |
748 | - public function set_price($data,$id) { |
|
748 | + public function set_price($data, $id) { |
|
749 | 749 | //Price |
750 | - if(isset($data['price']) && ''!== $data['price']){ |
|
750 | + if (isset($data['price']) && '' !== $data['price']) { |
|
751 | 751 | $price = preg_replace("/[^0-9,.]/", "", $data['price']); |
752 | - $this->save_custom_field($price,'price',$id); |
|
752 | + $this->save_custom_field($price, 'price', $id); |
|
753 | 753 | } |
754 | 754 | |
755 | 755 | //Price includes |
756 | - if(isset($data['price_includes']) && ''!== $data['price_includes']){ |
|
757 | - $this->save_custom_field($data['price_includes'],'included',$id); |
|
756 | + if (isset($data['price_includes']) && '' !== $data['price_includes']) { |
|
757 | + $this->save_custom_field($data['price_includes'], 'included', $id); |
|
758 | 758 | } |
759 | 759 | |
760 | 760 | //Price Excludes |
761 | - if(isset($data['price_excludes']) && ''!== $data['price_excludes']){ |
|
762 | - $this->save_custom_field($data['price_excludes'],'not_included',$id); |
|
761 | + if (isset($data['price_excludes']) && '' !== $data['price_excludes']) { |
|
762 | + $this->save_custom_field($data['price_excludes'], 'not_included', $id); |
|
763 | 763 | } |
764 | 764 | |
765 | 765 | } |
@@ -767,38 +767,38 @@ discard block |
||
767 | 767 | /** |
768 | 768 | * Set the duration |
769 | 769 | */ |
770 | - public function set_duration($data,$id) { |
|
771 | - if(isset($data['days']) && !empty($data['days'])){ |
|
770 | + public function set_duration($data, $id) { |
|
771 | + if (isset($data['days']) && !empty($data['days'])) { |
|
772 | 772 | $price = $data['days']; |
773 | 773 | $price = preg_replace("/[^0-9,.]/", "", $price); |
774 | - $this->save_custom_field($price,'duration',$id); |
|
774 | + $this->save_custom_field($price, 'duration', $id); |
|
775 | 775 | } |
776 | 776 | } |
777 | 777 | |
778 | 778 | /** |
779 | 779 | * Connects the Accommodation if its available |
780 | 780 | */ |
781 | - public function set_accommodation($day,$id) { |
|
781 | + public function set_accommodation($day, $id) { |
|
782 | 782 | |
783 | 783 | $ac_id = false; |
784 | 784 | $this->current_accommodation = $this->find_current_accommodation(); |
785 | 785 | |
786 | - if(isset($day['content_entity_id']) && !empty($day['content_entity_id'])){ |
|
786 | + if (isset($day['content_entity_id']) && !empty($day['content_entity_id'])) { |
|
787 | 787 | |
788 | - if(false !== $this->current_accommodation && !empty($this->current_accommodation) && array_key_exists($day['content_entity_id'],$this->current_accommodation)){ |
|
788 | + if (false !== $this->current_accommodation && !empty($this->current_accommodation) && array_key_exists($day['content_entity_id'], $this->current_accommodation)) { |
|
789 | 789 | $ac_id = $this->current_accommodation[$day['content_entity_id']]; |
790 | - }else{ |
|
790 | + }else { |
|
791 | 791 | $ac_id = wp_insert_post(array( |
792 | 792 | 'post_type' => 'accommodation', |
793 | 793 | 'post_status' => 'draft', |
794 | 794 | 'post_title' => $day['content_entity_id'] |
795 | 795 | )); |
796 | - $this->save_custom_field($day['content_entity_id'],'lsx_wetu_id',$ac_id); |
|
796 | + $this->save_custom_field($day['content_entity_id'], 'lsx_wetu_id', $ac_id); |
|
797 | 797 | } |
798 | 798 | |
799 | - if('' !== $ac_id && false !== $ac_id){ |
|
800 | - $this->save_custom_field($ac_id,'accommodation_to_tour',$id,false,false); |
|
801 | - $this->save_custom_field($id,'tour_to_accommodation',$ac_id,false,false); |
|
799 | + if ('' !== $ac_id && false !== $ac_id) { |
|
800 | + $this->save_custom_field($ac_id, 'accommodation_to_tour', $id, false, false); |
|
801 | + $this->save_custom_field($id, 'tour_to_accommodation', $ac_id, false, false); |
|
802 | 802 | } |
803 | 803 | } |
804 | 804 | return $ac_id; |
@@ -810,13 +810,13 @@ discard block |
||
810 | 810 | * @param $post_type string |
811 | 811 | * @return boolean / array |
812 | 812 | */ |
813 | - public function find_current_accommodation($post_type='accommodation') { |
|
813 | + public function find_current_accommodation($post_type = 'accommodation') { |
|
814 | 814 | global $wpdb; |
815 | 815 | $accommodation = parent::find_current_accommodation($post_type); |
816 | 816 | |
817 | 817 | $return = false; |
818 | - if(!empty($accommodation)){ |
|
819 | - foreach($accommodation as $key => $acc){ |
|
818 | + if (!empty($accommodation)) { |
|
819 | + foreach ($accommodation as $key => $acc) { |
|
820 | 820 | $return[$acc->meta_value] = $acc->post_id; |
821 | 821 | } |
822 | 822 | } |
@@ -838,25 +838,25 @@ discard block |
||
838 | 838 | * @param $id string |
839 | 839 | * @return boolean / string |
840 | 840 | */ |
841 | - public function set_destination($day,$id) { |
|
841 | + public function set_destination($day, $id) { |
|
842 | 842 | $dest_id = false; |
843 | 843 | $country_id = false; |
844 | 844 | $this->current_destinations = $this->find_current_destinations(); |
845 | 845 | |
846 | - if(isset($day['destination_content_entity_id']) && !empty($day['destination_content_entity_id'])){ |
|
846 | + if (isset($day['destination_content_entity_id']) && !empty($day['destination_content_entity_id'])) { |
|
847 | 847 | |
848 | - if(false !== $this->current_destinations && !empty($this->current_destinations) && array_key_exists($day['destination_content_entity_id'],$this->current_destinations)){ |
|
848 | + if (false !== $this->current_destinations && !empty($this->current_destinations) && array_key_exists($day['destination_content_entity_id'], $this->current_destinations)) { |
|
849 | 849 | $dest_id = $this->current_destinations[$day['destination_content_entity_id']]; |
850 | 850 | |
851 | 851 | $potential_id = wp_get_post_parent_id($dest_id); |
852 | - $country_wetu_id = get_post_meta($potential_id,'lsx_wetu_id',true); |
|
853 | - if(false !== $country_wetu_id){ |
|
852 | + $country_wetu_id = get_post_meta($potential_id, 'lsx_wetu_id', true); |
|
853 | + if (false !== $country_wetu_id) { |
|
854 | 854 | $this->set_country($country_wetu_id, $id); |
855 | 855 | } |
856 | 856 | |
857 | 857 | }else { |
858 | 858 | |
859 | - $destination_json = file_get_contents("http://wetu.com/API/Pins/".$this->api_key."/Get?ids=" . $day['destination_content_entity_id']); |
|
859 | + $destination_json = file_get_contents("http://wetu.com/API/Pins/".$this->api_key."/Get?ids=".$day['destination_content_entity_id']); |
|
860 | 860 | |
861 | 861 | if ($destination_json) { |
862 | 862 | $destination_data = json_decode($destination_json, true); |
@@ -865,12 +865,12 @@ discard block |
||
865 | 865 | |
866 | 866 | $destination_title = $day['destination_content_entity_id']; |
867 | 867 | |
868 | - if(isset($destination_data[0]['name'])){ |
|
868 | + if (isset($destination_data[0]['name'])) { |
|
869 | 869 | $destination_title = $destination_data[0]['name']; |
870 | 870 | } |
871 | 871 | |
872 | - if(isset($destination_data[0]['map_object_id']) && isset($destination_data[0]['position']['country_content_entity_id']) |
|
873 | - && $destination_data[0]['map_object_id'] !== $destination_data[0]['position']['country_content_entity_id']){ |
|
872 | + if (isset($destination_data[0]['map_object_id']) && isset($destination_data[0]['position']['country_content_entity_id']) |
|
873 | + && $destination_data[0]['map_object_id'] !== $destination_data[0]['position']['country_content_entity_id']) { |
|
874 | 874 | |
875 | 875 | $country_id = $this->set_country($destination_data[0]['position']['country_content_entity_id'], $id); |
876 | 876 | } |
@@ -881,7 +881,7 @@ discard block |
||
881 | 881 | 'post_title' => $destination_title |
882 | 882 | ); |
883 | 883 | |
884 | - if(false !== $country_id){ |
|
884 | + if (false !== $country_id) { |
|
885 | 885 | $dest_post['post_parent'] = $country_id; |
886 | 886 | } |
887 | 887 | $dest_id = wp_insert_post($dest_post); |
@@ -916,9 +916,9 @@ discard block |
||
916 | 916 | |
917 | 917 | if (false !== $this->current_destinations && !empty($this->current_destinations) && array_key_exists($country_wetu_id, $this->current_destinations)) { |
918 | 918 | $country_id = $this->current_destinations[$country_wetu_id]; |
919 | - } else { |
|
919 | + }else { |
|
920 | 920 | |
921 | - $country_json = file_get_contents("http://wetu.com/API/Pins/".$this->api_key."/Get?ids=" . $country_wetu_id); |
|
921 | + $country_json = file_get_contents("http://wetu.com/API/Pins/".$this->api_key."/Get?ids=".$country_wetu_id); |
|
922 | 922 | |
923 | 923 | if ($country_json) { |
924 | 924 | $country_data = json_decode($country_json, true); |
@@ -64,20 +64,20 @@ discard block |
||
64 | 64 | public function __construct() { |
65 | 65 | $this->set_variables(); |
66 | 66 | |
67 | - add_action( 'lsx_tour_importer_admin_tab_'.$this->tab_slug, array($this,'display_page') ); |
|
68 | - add_action('wp_ajax_lsx_tour_importer',array($this,'process_ajax_search')); |
|
69 | - add_action('wp_ajax_nopriv_lsx_tour_importer',array($this,'process_ajax_search')); |
|
67 | + add_action('lsx_tour_importer_admin_tab_'.$this->tab_slug, array($this, 'display_page')); |
|
68 | + add_action('wp_ajax_lsx_tour_importer', array($this, 'process_ajax_search')); |
|
69 | + add_action('wp_ajax_nopriv_lsx_tour_importer', array($this, 'process_ajax_search')); |
|
70 | 70 | |
71 | - add_action('wp_ajax_lsx_import_items',array($this,'process_ajax_import')); |
|
72 | - add_action('wp_ajax_nopriv_lsx_import_items',array($this,'process_ajax_import')); |
|
71 | + add_action('wp_ajax_lsx_import_items', array($this, 'process_ajax_import')); |
|
72 | + add_action('wp_ajax_nopriv_lsx_import_items', array($this, 'process_ajax_import')); |
|
73 | 73 | |
74 | - $temp_options = get_option('_lsx-to_settings',false); |
|
75 | - if(false !== $temp_options && isset($temp_options[$this->plugin_slug]) && !empty($temp_options[$this->plugin_slug])){ |
|
74 | + $temp_options = get_option('_lsx-to_settings', false); |
|
75 | + if (false !== $temp_options && isset($temp_options[$this->plugin_slug]) && !empty($temp_options[$this->plugin_slug])) { |
|
76 | 76 | $this->options = $temp_options[$this->plugin_slug]; |
77 | 77 | } |
78 | 78 | |
79 | - $accommodation_options = get_option('wetu_importer_accommodation_settings',false); |
|
80 | - if(false !== $accommodation_options){ |
|
79 | + $accommodation_options = get_option('wetu_importer_accommodation_settings', false); |
|
80 | + if (false !== $accommodation_options) { |
|
81 | 81 | $this->accommodation_options = $accommodation_options; |
82 | 82 | } |
83 | 83 | } |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | // $this->url = 'https://wetu.com/API/Pins/'; |
95 | 95 | // $this->url_qs = 'username=' . $this->api_username . '&password=' . $this->api_password; |
96 | 96 | //} elseif ( false !== $this->api_key ) { |
97 | - $this->url = 'https://wetu.com/API/Pins/' . $this->api_key; |
|
97 | + $this->url = 'https://wetu.com/API/Pins/'.$this->api_key; |
|
98 | 98 | $this->url_qs = ''; |
99 | 99 | //} |
100 | 100 | } |
@@ -102,27 +102,27 @@ discard block |
||
102 | 102 | /** |
103 | 103 | * search_form |
104 | 104 | */ |
105 | - public function get_scaling_url($args=array()) { |
|
105 | + public function get_scaling_url($args = array()) { |
|
106 | 106 | |
107 | 107 | $defaults = array( |
108 | 108 | 'width' => '640', |
109 | 109 | 'height' => '480', |
110 | 110 | 'cropping' => 'c' |
111 | 111 | ); |
112 | - if(false !== $this->options){ |
|
113 | - if(isset($this->options['width']) && '' !== $this->options['width']){ |
|
112 | + if (false !== $this->options) { |
|
113 | + if (isset($this->options['width']) && '' !== $this->options['width']) { |
|
114 | 114 | $defaults['width'] = $this->options['width']; |
115 | 115 | } |
116 | 116 | |
117 | - if(isset($this->options['height']) && '' !== $this->options['height']){ |
|
117 | + if (isset($this->options['height']) && '' !== $this->options['height']) { |
|
118 | 118 | $defaults['height'] = $this->options['height']; |
119 | 119 | } |
120 | 120 | |
121 | - if(isset($this->options['cropping']) && '' !== $this->options['cropping']){ |
|
121 | + if (isset($this->options['cropping']) && '' !== $this->options['cropping']) { |
|
122 | 122 | $defaults['cropping'] = $this->options['cropping']; |
123 | 123 | } |
124 | 124 | } |
125 | - $args = wp_parse_args($args,$defaults); |
|
125 | + $args = wp_parse_args($args, $defaults); |
|
126 | 126 | |
127 | 127 | $cropping = $args['cropping']; |
128 | 128 | $width = $args['width']; |
@@ -147,8 +147,8 @@ discard block |
||
147 | 147 | <form method="get" action="" id="posts-filter"> |
148 | 148 | <input type="hidden" name="post_type" class="post_type" value="<?php echo $this->tab_slug; ?>" /> |
149 | 149 | |
150 | - <p><input class="button button-primary add" type="button" value="<?php _e('Add to List','wetu-importer'); ?>" /> |
|
151 | - <input class="button button-primary clear" type="button" value="<?php _e('Clear','wetu-importer'); ?>" /> |
|
150 | + <p><input class="button button-primary add" type="button" value="<?php _e('Add to List', 'wetu-importer'); ?>" /> |
|
151 | + <input class="button button-primary clear" type="button" value="<?php _e('Clear', 'wetu-importer'); ?>" /> |
|
152 | 152 | </p> |
153 | 153 | |
154 | 154 | <table class="wp-list-table widefat fixed posts"> |
@@ -157,11 +157,11 @@ discard block |
||
157 | 157 | <tbody id="the-list"> |
158 | 158 | <tr class="post-0 type-tour status-none" id="post-0"> |
159 | 159 | <th class="check-column" scope="row"> |
160 | - <label for="cb-select-0" class="screen-reader-text"><?php _e('Enter a title to search for and press enter','wetu-importer'); ?></label> |
|
160 | + <label for="cb-select-0" class="screen-reader-text"><?php _e('Enter a title to search for and press enter', 'wetu-importer'); ?></label> |
|
161 | 161 | </th> |
162 | 162 | <td class="post-title page-title column-title"> |
163 | 163 | <strong> |
164 | - <?php _e('Enter a title to search for','wetu-importer'); ?> |
|
164 | + <?php _e('Enter a title to search for', 'wetu-importer'); ?> |
|
165 | 165 | </strong> |
166 | 166 | </td> |
167 | 167 | <td class="date column-date"> |
@@ -175,8 +175,8 @@ discard block |
||
175 | 175 | |
176 | 176 | </table> |
177 | 177 | |
178 | - <p><input class="button button-primary add" type="button" value="<?php _e('Add to List','wetu-importer'); ?>" /> |
|
179 | - <input class="button button-primary clear" type="button" value="<?php _e('Clear','wetu-importer'); ?>" /> |
|
178 | + <p><input class="button button-primary add" type="button" value="<?php _e('Add to List', 'wetu-importer'); ?>" /> |
|
179 | + <input class="button button-primary clear" type="button" value="<?php _e('Clear', 'wetu-importer'); ?>" /> |
|
180 | 180 | </p> |
181 | 181 | </form> |
182 | 182 | |
@@ -188,32 +188,32 @@ discard block |
||
188 | 188 | <div class="settings-all" style="width:30%;display:block;float:left;"> |
189 | 189 | <h3><?php _e('What content to Sync from WETU'); ?></h3> |
190 | 190 | <ul> |
191 | - <li><input class="content select-all" <?php $this->checked($this->destination_options,'all'); ?> type="checkbox"name="content[]" value="all" /> <?php _e('Select All','wetu-importer'); ?></li> |
|
192 | - <li><input class="content" checked="<?php $this->checked($this->accommodation_options,'description'); ?>" type="checkbox" name="content[]" value="description" /> <?php _e('Description','wetu-importer'); ?></li> |
|
193 | - <li><input class="content" checked="<?php $this->checked($this->accommodation_options,'excerpt'); ?>" type="checkbox" name="content[]" value="excerpt" /> <?php _e('Excerpt','wetu-importer'); ?></li> |
|
194 | - <li><input class="content" checked="<?php $this->checked($this->accommodation_options,'gallery'); ?>" type="checkbox" name="content[]" value="gallery" /> <?php _e('Main Gallery','wetu-importer'); ?></li> |
|
195 | - <li><input class="content" checked="<?php $this->checked($this->accommodation_options,'category'); ?>" type="checkbox" name="content[]" value="category" /> <?php _e('Category','wetu-importer'); ?></li> |
|
196 | - <?php if(class_exists('LSX_TO_Maps')){ ?> |
|
197 | - <li><input class="content" checked="<?php $this->checked($this->accommodation_options,'location'); ?>" type="checkbox" name="content[]" value="location" /> <?php _e('Location','wetu-importer'); ?></li> |
|
191 | + <li><input class="content select-all" <?php $this->checked($this->destination_options, 'all'); ?> type="checkbox"name="content[]" value="all" /> <?php _e('Select All', 'wetu-importer'); ?></li> |
|
192 | + <li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'description'); ?>" type="checkbox" name="content[]" value="description" /> <?php _e('Description', 'wetu-importer'); ?></li> |
|
193 | + <li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'excerpt'); ?>" type="checkbox" name="content[]" value="excerpt" /> <?php _e('Excerpt', 'wetu-importer'); ?></li> |
|
194 | + <li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'gallery'); ?>" type="checkbox" name="content[]" value="gallery" /> <?php _e('Main Gallery', 'wetu-importer'); ?></li> |
|
195 | + <li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'category'); ?>" type="checkbox" name="content[]" value="category" /> <?php _e('Category', 'wetu-importer'); ?></li> |
|
196 | + <?php if (class_exists('LSX_TO_Maps')) { ?> |
|
197 | + <li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'location'); ?>" type="checkbox" name="content[]" value="location" /> <?php _e('Location', 'wetu-importer'); ?></li> |
|
198 | 198 | <?php } ?> |
199 | - <li><input class="content" checked="<?php $this->checked($this->accommodation_options,'destination'); ?>" type="checkbox" name="content[]" value="destination" /> <?php _e('Connect Destinations','wetu-importer'); ?></li> |
|
200 | - <li><input class="content" checked="<?php $this->checked($this->accommodation_options,'checkin'); ?>" type="checkbox" name="content[]" value="checkin" /> <?php _e('Check In / Check Out','wetu-importer'); ?></li> |
|
201 | - <li><input class="content" checked="<?php $this->checked($this->accommodation_options,'facilities'); ?>" type="checkbox" name="content[]" value="facilities" /> <?php _e('Facilities','wetu-importer'); ?></li> |
|
202 | - <li><input class="content" checked="<?php $this->checked($this->accommodation_options,'friendly'); ?>" type="checkbox" name="content[]" value="friendly" /> <?php _e('Friendly','wetu-importer'); ?></li> |
|
203 | - <li><input class="content" checked="<?php $this->checked($this->accommodation_options,'rating'); ?>" type="checkbox" name="content[]" value="rating" /> <?php _e('Rating','wetu-importer'); ?></li> |
|
204 | - <li><input class="content" checked="<?php $this->checked($this->accommodation_options,'rooms'); ?>" type="checkbox" name="content[]" value="rooms" /> <?php _e('Rooms','wetu-importer'); ?></li> |
|
205 | - <li><input class="content" checked="<?php $this->checked($this->accommodation_options,'special_interests'); ?>" type="checkbox" name="content[]" value="special_interests" /> <?php _e('Special Interests','wetu-importer'); ?></li> |
|
206 | - <li><input class="content" checked="<?php $this->checked($this->accommodation_options,'spoken_languages'); ?>" type="checkbox" name="content[]" value="spoken_languages" /> <?php _e('Spoken Languages','wetu-importer'); ?></li> |
|
207 | - |
|
208 | - <?php if(class_exists('LSX_TO_Videos')){ ?> |
|
209 | - <li><input class="content" checked="<?php $this->checked($this->accommodation_options,'videos'); ?>" type="checkbox" name="content[]" value="videos" /> <?php _e('Videos','wetu-importer'); ?></li> |
|
199 | + <li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'destination'); ?>" type="checkbox" name="content[]" value="destination" /> <?php _e('Connect Destinations', 'wetu-importer'); ?></li> |
|
200 | + <li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'checkin'); ?>" type="checkbox" name="content[]" value="checkin" /> <?php _e('Check In / Check Out', 'wetu-importer'); ?></li> |
|
201 | + <li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'facilities'); ?>" type="checkbox" name="content[]" value="facilities" /> <?php _e('Facilities', 'wetu-importer'); ?></li> |
|
202 | + <li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'friendly'); ?>" type="checkbox" name="content[]" value="friendly" /> <?php _e('Friendly', 'wetu-importer'); ?></li> |
|
203 | + <li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'rating'); ?>" type="checkbox" name="content[]" value="rating" /> <?php _e('Rating', 'wetu-importer'); ?></li> |
|
204 | + <li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'rooms'); ?>" type="checkbox" name="content[]" value="rooms" /> <?php _e('Rooms', 'wetu-importer'); ?></li> |
|
205 | + <li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'special_interests'); ?>" type="checkbox" name="content[]" value="special_interests" /> <?php _e('Special Interests', 'wetu-importer'); ?></li> |
|
206 | + <li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'spoken_languages'); ?>" type="checkbox" name="content[]" value="spoken_languages" /> <?php _e('Spoken Languages', 'wetu-importer'); ?></li> |
|
207 | + |
|
208 | + <?php if (class_exists('LSX_TO_Videos')) { ?> |
|
209 | + <li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'videos'); ?>" type="checkbox" name="content[]" value="videos" /> <?php _e('Videos', 'wetu-importer'); ?></li> |
|
210 | 210 | <?php } ?> |
211 | 211 | </ul> |
212 | 212 | <h4><?php _e('Additional Content'); ?></h4> |
213 | 213 | <ul> |
214 | - <li><input class="content" checked="<?php $this->checked($this->accommodation_options,'featured_image'); ?>" type="checkbox" name="content[]" value="featured_image" /> <?php _e('Set Featured Image','wetu-importer'); ?></li> |
|
215 | - <?php if(class_exists('LSX_Banners')){ ?> |
|
216 | - <li><input class="content" checked="<?php $this->checked($this->accommodation_options,'banner_image'); ?>" type="checkbox" name="content[]" value="banner_image" /> <?php _e('Set Banner Image','wetu-importer'); ?></li> |
|
214 | + <li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'featured_image'); ?>" type="checkbox" name="content[]" value="featured_image" /> <?php _e('Set Featured Image', 'wetu-importer'); ?></li> |
|
215 | + <?php if (class_exists('LSX_Banners')) { ?> |
|
216 | + <li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'banner_image'); ?>" type="checkbox" name="content[]" value="banner_image" /> <?php _e('Set Banner Image', 'wetu-importer'); ?></li> |
|
217 | 217 | <?php } ?> |
218 | 218 | </ul> |
219 | 219 | </div> |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | |
225 | 225 | <div style="width:30%;display:block;float:left;"> |
226 | 226 | <h3><?php _e('Assign a Safari Brand'); ?></h3> |
227 | - <?php echo $this->taxonomy_checkboxes('accommodation-brand',$this->accommodation_options); ?> |
|
227 | + <?php echo $this->taxonomy_checkboxes('accommodation-brand', $this->accommodation_options); ?> |
|
228 | 228 | </div> |
229 | 229 | |
230 | 230 | <br clear="both" /> |
@@ -232,7 +232,7 @@ discard block |
||
232 | 232 | |
233 | 233 | |
234 | 234 | <h3><?php _e('Your List'); ?></h3> |
235 | - <p><input class="button button-primary" type="submit" value="<?php _e('Sync','wetu-importer'); ?>" /></p> |
|
235 | + <p><input class="button button-primary" type="submit" value="<?php _e('Sync', 'wetu-importer'); ?>" /></p> |
|
236 | 236 | <table class="wp-list-table widefat fixed posts"> |
237 | 237 | <?php $this->table_header(); ?> |
238 | 238 | |
@@ -244,12 +244,12 @@ discard block |
||
244 | 244 | |
245 | 245 | </table> |
246 | 246 | |
247 | - <p><input class="button button-primary" type="submit" value="<?php _e('Sync','wetu-importer'); ?>" /></p> |
|
247 | + <p><input class="button button-primary" type="submit" value="<?php _e('Sync', 'wetu-importer'); ?>" /></p> |
|
248 | 248 | </form> |
249 | 249 | </div> |
250 | 250 | |
251 | 251 | <div style="display:none;" class="completed-list-wrapper"> |
252 | - <h3><?php _e('Completed'); ?> - <small><?php _e('Import your','wetu-importer'); ?> <a href="<?php echo admin_url('admin.php'); ?>?page=<?php echo $this->plugin_slug; ?>&tab=destination"><?php _e('destinations'); ?></a> <?php _e('next','wetu-importer'); ?></small></h3> |
|
252 | + <h3><?php _e('Completed'); ?> - <small><?php _e('Import your', 'wetu-importer'); ?> <a href="<?php echo admin_url('admin.php'); ?>?page=<?php echo $this->plugin_slug; ?>&tab=destination"><?php _e('destinations'); ?></a> <?php _e('next', 'wetu-importer'); ?></small></h3> |
|
253 | 253 | <ul> |
254 | 254 | </ul> |
255 | 255 | </div> |
@@ -265,30 +265,30 @@ discard block |
||
265 | 265 | <form class="ajax-form" id="<?php echo $this->plugin_slug; ?>-search-form" method="get" action="tools.php" data-type="<?php echo $this->tab_slug; ?>"> |
266 | 266 | <input type="hidden" name="page" value="<?php echo $this->tab_slug; ?>" /> |
267 | 267 | |
268 | - <h3><span class="dashicons dashicons-search"></span> <?php _e('Search','wetu-importer'); ?></h3> |
|
268 | + <h3><span class="dashicons dashicons-search"></span> <?php _e('Search', 'wetu-importer'); ?></h3> |
|
269 | 269 | <div class="normal-search"> |
270 | - <input pattern=".{3,}" placeholder="3 characters minimum" class="keyword" name="keyword" value=""> <input class="button button-primary submit" type="submit" value="<?php _e('Search','wetu-importer'); ?>" /> |
|
270 | + <input pattern=".{3,}" placeholder="3 characters minimum" class="keyword" name="keyword" value=""> <input class="button button-primary submit" type="submit" value="<?php _e('Search', 'wetu-importer'); ?>" /> |
|
271 | 271 | </div> |
272 | 272 | <div class="advanced-search hidden" style="display:none;"> |
273 | - <p><?php _e('Enter several keywords, each on a new line.','wetu-importer'); ?></p> |
|
273 | + <p><?php _e('Enter several keywords, each on a new line.', 'wetu-importer'); ?></p> |
|
274 | 274 | <textarea rows="10" cols="40" name="bulk-keywords"></textarea> |
275 | - <input class="button button-primary submit" type="submit" value="<?php _e('Search','wetu-importer'); ?>" /> |
|
275 | + <input class="button button-primary submit" type="submit" value="<?php _e('Search', 'wetu-importer'); ?>" /> |
|
276 | 276 | </div> |
277 | 277 | |
278 | 278 | <p> |
279 | - <a class="advanced-search-toggle" href="#"><?php _e('Bulk Search','wetu-importer'); ?></a> | |
|
280 | - <a class="published search-toggle" href="#publish"><?php esc_attr_e('Published','wetu-importer'); ?></a> | |
|
281 | - <a class="pending search-toggle" href="#pending"><?php esc_attr_e('Pending','wetu-importer'); ?></a> | |
|
282 | - <a class="draft search-toggle" href="#draft"><?php esc_attr_e('Draft','wetu-importer'); ?></a> | |
|
283 | - <a class="import search-toggle" href="#import"><?php esc_attr_e('WETU','wetu-importer'); ?></a> |
|
279 | + <a class="advanced-search-toggle" href="#"><?php _e('Bulk Search', 'wetu-importer'); ?></a> | |
|
280 | + <a class="published search-toggle" href="#publish"><?php esc_attr_e('Published', 'wetu-importer'); ?></a> | |
|
281 | + <a class="pending search-toggle" href="#pending"><?php esc_attr_e('Pending', 'wetu-importer'); ?></a> | |
|
282 | + <a class="draft search-toggle" href="#draft"><?php esc_attr_e('Draft', 'wetu-importer'); ?></a> | |
|
283 | + <a class="import search-toggle" href="#import"><?php esc_attr_e('WETU', 'wetu-importer'); ?></a> |
|
284 | 284 | </p> |
285 | 285 | |
286 | 286 | <div class="ajax-loader" style="display:none;width:100%;text-align:center;"> |
287 | - <img style="width:64px;" src="<?php echo WETU_IMPORTER_URL.'assets/images/ajaxloader.gif';?>" /> |
|
287 | + <img style="width:64px;" src="<?php echo WETU_IMPORTER_URL.'assets/images/ajaxloader.gif'; ?>" /> |
|
288 | 288 | </div> |
289 | 289 | |
290 | 290 | <div class="ajax-loader-small" style="display:none;width:100%;text-align:center;"> |
291 | - <img style="width:32px;" src="<?php echo WETU_IMPORTER_URL.'assets/images/ajaxloader.gif';?>" /> |
|
291 | + <img style="width:32px;" src="<?php echo WETU_IMPORTER_URL.'assets/images/ajaxloader.gif'; ?>" /> |
|
292 | 292 | </div> |
293 | 293 | </form> |
294 | 294 | <?php |
@@ -298,9 +298,9 @@ discard block |
||
298 | 298 | * search_form |
299 | 299 | */ |
300 | 300 | public function update_options_form() { |
301 | - echo '<div style="display:none;" class="wetu-status"><h3>'.__('Wetu Status','wetu-importer').'</h3>'; |
|
301 | + echo '<div style="display:none;" class="wetu-status"><h3>'.__('Wetu Status', 'wetu-importer').'</h3>'; |
|
302 | 302 | $accommodation = get_transient('lsx_ti_accommodation'); |
303 | - if('' === $accommodation || false === $accommodation || isset($_GET['refresh_accommodation'])){ |
|
303 | + if ('' === $accommodation || false === $accommodation || isset($_GET['refresh_accommodation'])) { |
|
304 | 304 | $this->update_options(); |
305 | 305 | } |
306 | 306 | echo '</div>'; |
@@ -311,13 +311,13 @@ discard block |
||
311 | 311 | * Save the list of Accommodation into an option |
312 | 312 | */ |
313 | 313 | public function update_options() { |
314 | - $data = file_get_contents( $this->url . '/List?' . $this->url_qs ); |
|
314 | + $data = file_get_contents($this->url.'/List?'.$this->url_qs); |
|
315 | 315 | $accommodation = json_decode($data, true); |
316 | 316 | |
317 | - if(isset($accommodation['error'])){ |
|
317 | + if (isset($accommodation['error'])) { |
|
318 | 318 | return $accommodation['error']; |
319 | 319 | }elseif (isset($accommodation) && !empty($accommodation)) { |
320 | - set_transient('lsx_ti_accommodation',$accommodation,60*60*2); |
|
320 | + set_transient('lsx_ti_accommodation', $accommodation, 60 * 60 * 2); |
|
321 | 321 | return true; |
322 | 322 | } |
323 | 323 | } |
@@ -325,7 +325,7 @@ discard block |
||
325 | 325 | /** |
326 | 326 | * Grab all the current accommodation posts via the lsx_wetu_id field. |
327 | 327 | */ |
328 | - public function find_current_accommodation($post_type='accommodation') { |
|
328 | + public function find_current_accommodation($post_type = 'accommodation') { |
|
329 | 329 | global $wpdb; |
330 | 330 | $return = array(); |
331 | 331 | |
@@ -341,8 +341,8 @@ discard block |
||
341 | 341 | |
342 | 342 | LIMIT 0,500 |
343 | 343 | "); |
344 | - if(null !== $current_accommodation && !empty($current_accommodation)){ |
|
345 | - foreach($current_accommodation as $accom){ |
|
344 | + if (null !== $current_accommodation && !empty($current_accommodation)) { |
|
345 | + foreach ($current_accommodation as $accom) { |
|
346 | 346 | $return[$accom->meta_value] = $accom; |
347 | 347 | } |
348 | 348 | } |
@@ -354,37 +354,37 @@ discard block |
||
354 | 354 | */ |
355 | 355 | public function process_ajax_search() { |
356 | 356 | $return = false; |
357 | - if(isset($_POST['action']) && $_POST['action'] === 'lsx_tour_importer' && isset($_POST['type']) && $_POST['type'] === 'accommodation'){ |
|
357 | + if (isset($_POST['action']) && $_POST['action'] === 'lsx_tour_importer' && isset($_POST['type']) && $_POST['type'] === 'accommodation') { |
|
358 | 358 | $accommodation = get_transient('lsx_ti_accommodation'); |
359 | 359 | |
360 | - if ( false !== $accommodation ) { |
|
360 | + if (false !== $accommodation) { |
|
361 | 361 | $searched_items = false; |
362 | 362 | |
363 | - if(isset($_POST['keyword'] )) { |
|
363 | + if (isset($_POST['keyword'])) { |
|
364 | 364 | $keyphrases = $_POST['keyword']; |
365 | - }else{ |
|
365 | + }else { |
|
366 | 366 | $keyphrases = array(0); |
367 | 367 | } |
368 | 368 | |
369 | - if(!is_array($keyphrases)){ |
|
369 | + if (!is_array($keyphrases)) { |
|
370 | 370 | $keyphrases = array($keyphrases); |
371 | 371 | } |
372 | - foreach($keyphrases as &$keyword){ |
|
372 | + foreach ($keyphrases as &$keyword) { |
|
373 | 373 | $keyword = ltrim(rtrim($keyword)); |
374 | 374 | } |
375 | 375 | |
376 | 376 | |
377 | 377 | $post_status = false; |
378 | - if(in_array('publish',$keyphrases)){ |
|
378 | + if (in_array('publish', $keyphrases)) { |
|
379 | 379 | $post_status = 'publish'; |
380 | 380 | } |
381 | - if(in_array('pending',$keyphrases)){ |
|
381 | + if (in_array('pending', $keyphrases)) { |
|
382 | 382 | $post_status = 'pending'; |
383 | 383 | } |
384 | - if(in_array('draft',$keyphrases)){ |
|
384 | + if (in_array('draft', $keyphrases)) { |
|
385 | 385 | $post_status = 'draft'; |
386 | 386 | } |
387 | - if(in_array('import',$keyphrases)){ |
|
387 | + if (in_array('import', $keyphrases)) { |
|
388 | 388 | $post_status = 'import'; |
389 | 389 | } |
390 | 390 | |
@@ -392,33 +392,33 @@ discard block |
||
392 | 392 | |
393 | 393 | $current_accommodation = $this->find_current_accommodation(); |
394 | 394 | |
395 | - foreach($accommodation as $row_key => $row){ |
|
395 | + foreach ($accommodation as $row_key => $row) { |
|
396 | 396 | |
397 | 397 | //If this is a current tour, add its ID to the row. |
398 | 398 | $row['post_id'] = 0; |
399 | - if(false !== $current_accommodation && array_key_exists($row['id'], $current_accommodation)){ |
|
399 | + if (false !== $current_accommodation && array_key_exists($row['id'], $current_accommodation)) { |
|
400 | 400 | $row['post_id'] = $current_accommodation[$row['id']]->post_id; |
401 | 401 | } |
402 | 402 | |
403 | 403 | //If we are searching for |
404 | - if(false !== $post_status){ |
|
404 | + if (false !== $post_status) { |
|
405 | 405 | |
406 | - if('import' === $post_status){ |
|
406 | + if ('import' === $post_status) { |
|
407 | 407 | |
408 | - if(0 !== $row['post_id']){ |
|
408 | + if (0 !== $row['post_id']) { |
|
409 | 409 | continue; |
410 | - }else{ |
|
410 | + }else { |
|
411 | 411 | $searched_items[sanitize_title($row['name']).'-'.$row['id']] = $this->format_row($row); |
412 | 412 | } |
413 | 413 | |
414 | 414 | |
415 | - }else{ |
|
415 | + }else { |
|
416 | 416 | |
417 | - if(0 === $row['post_id']){ |
|
417 | + if (0 === $row['post_id']) { |
|
418 | 418 | continue; |
419 | - }else{ |
|
419 | + }else { |
|
420 | 420 | $current_status = get_post_status($row['post_id']); |
421 | - if($current_status !== $post_status){ |
|
421 | + if ($current_status !== $post_status) { |
|
422 | 422 | continue; |
423 | 423 | } |
424 | 424 | |
@@ -426,17 +426,17 @@ discard block |
||
426 | 426 | $searched_items[sanitize_title($row['name']).'-'.$row['id']] = $this->format_row($row); |
427 | 427 | } |
428 | 428 | |
429 | - }else{ |
|
429 | + }else { |
|
430 | 430 | //Search through each keyword. |
431 | - foreach($keyphrases as $keyphrase){ |
|
431 | + foreach ($keyphrases as $keyphrase) { |
|
432 | 432 | |
433 | 433 | //Make sure the keyphrase is turned into an array |
434 | - $keywords = explode(" ",$keyphrase); |
|
435 | - if(!is_array($keywords)){ |
|
434 | + $keywords = explode(" ", $keyphrase); |
|
435 | + if (!is_array($keywords)) { |
|
436 | 436 | $keywords = array($keywords); |
437 | 437 | } |
438 | 438 | |
439 | - if($this->multineedle_stripos(ltrim(rtrim($row['name'])), $keywords) !== false){ |
|
439 | + if ($this->multineedle_stripos(ltrim(rtrim($row['name'])), $keywords) !== false) { |
|
440 | 440 | $searched_items[sanitize_title($row['name']).'-'.$row['id']] = $this->format_row($row); |
441 | 441 | } |
442 | 442 | } |
@@ -445,7 +445,7 @@ discard block |
||
445 | 445 | } |
446 | 446 | |
447 | 447 | |
448 | - if(false !== $searched_items){ |
|
448 | + if (false !== $searched_items) { |
|
449 | 449 | ksort($searched_items); |
450 | 450 | $return = implode($searched_items); |
451 | 451 | } |
@@ -458,17 +458,17 @@ discard block |
||
458 | 458 | /** |
459 | 459 | * Does a multine search |
460 | 460 | */ |
461 | - public function multineedle_stripos($haystack, $needles, $offset=0) { |
|
461 | + public function multineedle_stripos($haystack, $needles, $offset = 0) { |
|
462 | 462 | $found = false; |
463 | 463 | $needle_count = count($needles); |
464 | - foreach($needles as $needle) { |
|
465 | - if(false !== stripos($haystack, $needle, $offset)){ |
|
464 | + foreach ($needles as $needle) { |
|
465 | + if (false !== stripos($haystack, $needle, $offset)) { |
|
466 | 466 | $found[] = true; |
467 | 467 | } |
468 | 468 | } |
469 | - if(false !== $found && $needle_count === count($found)){ |
|
469 | + if (false !== $found && $needle_count === count($found)) { |
|
470 | 470 | return true; |
471 | - }else{ |
|
471 | + }else { |
|
472 | 472 | return false; |
473 | 473 | } |
474 | 474 | } |
@@ -476,11 +476,11 @@ discard block |
||
476 | 476 | /** |
477 | 477 | * Formats the row for output on the screen. |
478 | 478 | */ |
479 | - public function format_row($row = false){ |
|
480 | - if(false !== $row){ |
|
479 | + public function format_row($row = false) { |
|
480 | + if (false !== $row) { |
|
481 | 481 | |
482 | 482 | $status = 'import'; |
483 | - if(0 !== $row['post_id']){ |
|
483 | + if (0 !== $row['post_id']) { |
|
484 | 484 | $status = '<a href="'.admin_url('/post.php?post='.$row['post_id'].'&action=edit').'" target="_blank">'.get_post_status($row['post_id']).'</a>'; |
485 | 485 | } |
486 | 486 | |
@@ -494,7 +494,7 @@ discard block |
||
494 | 494 | <strong>'.$row['name'].'</strong> - '.$status.' |
495 | 495 | </td> |
496 | 496 | <td class="date column-date"> |
497 | - <abbr title="'.date('Y/m/d',strtotime($row['last_modified'])).'">'.date('Y/m/d',strtotime($row['last_modified'])).'</abbr><br>Last Modified |
|
497 | + <abbr title="'.date('Y/m/d', strtotime($row['last_modified'])).'">'.date('Y/m/d', strtotime($row['last_modified'])).'</abbr><br>Last Modified |
|
498 | 498 | </td> |
499 | 499 | <td class="ssid column-ssid"> |
500 | 500 | '.$row['id'].' |
@@ -509,42 +509,42 @@ discard block |
||
509 | 509 | */ |
510 | 510 | public function process_ajax_import() { |
511 | 511 | $return = false; |
512 | - if(isset($_POST['action']) && $_POST['action'] === 'lsx_import_items' && isset($_POST['type']) && $_POST['type'] === 'accommodation' && isset($_POST['wetu_id'])){ |
|
512 | + if (isset($_POST['action']) && $_POST['action'] === 'lsx_import_items' && isset($_POST['type']) && $_POST['type'] === 'accommodation' && isset($_POST['wetu_id'])) { |
|
513 | 513 | |
514 | 514 | $wetu_id = $_POST['wetu_id']; |
515 | - if(isset($_POST['post_id'])){ |
|
515 | + if (isset($_POST['post_id'])) { |
|
516 | 516 | $post_id = $_POST['post_id']; |
517 | - }else{ |
|
517 | + }else { |
|
518 | 518 | $post_id = 0; |
519 | 519 | } |
520 | 520 | |
521 | - if(isset($_POST['team_members'])){ |
|
521 | + if (isset($_POST['team_members'])) { |
|
522 | 522 | $team_members = $_POST['team_members']; |
523 | - }else{ |
|
523 | + }else { |
|
524 | 524 | $team_members = false; |
525 | 525 | } |
526 | 526 | |
527 | - if(isset($_POST['safari_brands'])){ |
|
527 | + if (isset($_POST['safari_brands'])) { |
|
528 | 528 | $safari_brands = $_POST['safari_brands']; |
529 | - }else{ |
|
529 | + }else { |
|
530 | 530 | $safari_brands = false; |
531 | 531 | } |
532 | 532 | |
533 | - if(isset($_POST['content']) && is_array($_POST['content']) && !empty($_POST['content'])){ |
|
533 | + if (isset($_POST['content']) && is_array($_POST['content']) && !empty($_POST['content'])) { |
|
534 | 534 | $content = $_POST['content']; |
535 | - add_option('wetu_importer_accommodation_settings',$content); |
|
536 | - }else{ |
|
535 | + add_option('wetu_importer_accommodation_settings', $content); |
|
536 | + }else { |
|
537 | 537 | delete_option('wetu_importer_accommodation_settings'); |
538 | 538 | $content = false; |
539 | 539 | } |
540 | 540 | |
541 | - $jdata = file_get_contents( $this->url . '/Get?' . $this->url_qs . '&ids=' . $wetu_id ); |
|
542 | - if($jdata) |
|
541 | + $jdata = file_get_contents($this->url.'/Get?'.$this->url_qs.'&ids='.$wetu_id); |
|
542 | + if ($jdata) |
|
543 | 543 | { |
544 | - $adata=json_decode($jdata,true); |
|
545 | - if(!empty($adata)) |
|
544 | + $adata = json_decode($jdata, true); |
|
545 | + if (!empty($adata)) |
|
546 | 546 | { |
547 | - $return = $this->import_row($adata,$wetu_id,$post_id,$team_members,$content,$safari_brands); |
|
547 | + $return = $this->import_row($adata, $wetu_id, $post_id, $team_members, $content, $safari_brands); |
|
548 | 548 | $this->format_completed_row($return); |
549 | 549 | $this->cleanup_posts(); |
550 | 550 | } |
@@ -557,15 +557,15 @@ discard block |
||
557 | 557 | /** |
558 | 558 | * Formats the row for the completed list. |
559 | 559 | */ |
560 | - public function format_completed_row($response){ |
|
560 | + public function format_completed_row($response) { |
|
561 | 561 | echo '<li class="post-'.$response.'"><span class="dashicons dashicons-yes"></span> <a target="_blank" href="'.get_permalink($response).'">'.get_the_title($response).'</a></li>'; |
562 | 562 | } |
563 | 563 | /** |
564 | 564 | * Connect to wetu |
565 | 565 | */ |
566 | - public function import_row($data,$wetu_id,$id=0,$team_members=false,$importable_content=false,$safari_brands=false) { |
|
566 | + public function import_row($data, $wetu_id, $id = 0, $team_members = false, $importable_content = false, $safari_brands = false) { |
|
567 | 567 | |
568 | - if(trim($data[0]['type'])=='Accommodation') |
|
568 | + if (trim($data[0]['type']) == 'Accommodation') |
|
569 | 569 | { |
570 | 570 | $post_name = $data_post_content = $data_post_excerpt = ''; |
571 | 571 | $post = array( |
@@ -575,44 +575,44 @@ discard block |
||
575 | 575 | $content_used_general_description = false; |
576 | 576 | |
577 | 577 | //Set the post_content |
578 | - if(false !== $importable_content && in_array('description',$importable_content)){ |
|
579 | - if(isset($data[0]['content']['extended_description'])) |
|
578 | + if (false !== $importable_content && in_array('description', $importable_content)) { |
|
579 | + if (isset($data[0]['content']['extended_description'])) |
|
580 | 580 | { |
581 | 581 | $data_post_content = $data[0]['content']['extended_description']; |
582 | - }elseif(isset($data[0]['content']['general_description'])){ |
|
582 | + }elseif (isset($data[0]['content']['general_description'])) { |
|
583 | 583 | $data_post_content = $data[0]['content']['general_description']; |
584 | 584 | $content_used_general_description = true; |
585 | - }elseif(isset($data[0]['content']['teaser_description'])){ |
|
585 | + }elseif (isset($data[0]['content']['teaser_description'])) { |
|
586 | 586 | $data_post_content = $data[0]['content']['teaser_description']; |
587 | 587 | } |
588 | 588 | $post['post_content'] = wp_strip_all_tags($data_post_content); |
589 | 589 | } |
590 | 590 | |
591 | 591 | //set the post_excerpt |
592 | - if(false !== $importable_content && in_array('excerpt',$importable_content)){ |
|
593 | - if(isset($data[0]['content']['teaser_description'])){ |
|
592 | + if (false !== $importable_content && in_array('excerpt', $importable_content)) { |
|
593 | + if (isset($data[0]['content']['teaser_description'])) { |
|
594 | 594 | $data_post_excerpt = $data[0]['content']['teaser_description']; |
595 | - }elseif(isset($data[0]['content']['general_description']) && false === $content_used_general_description){ |
|
595 | + }elseif (isset($data[0]['content']['general_description']) && false === $content_used_general_description) { |
|
596 | 596 | $data_post_excerpt = $data[0]['content']['general_description']; |
597 | 597 | } |
598 | 598 | $post['post_excerpt'] = $data_post_excerpt; |
599 | 599 | } |
600 | 600 | |
601 | - if(false !== $id && '0' !== $id){ |
|
601 | + if (false !== $id && '0' !== $id) { |
|
602 | 602 | $post['ID'] = $id; |
603 | - if(isset($data[0]['name'])){ |
|
603 | + if (isset($data[0]['name'])) { |
|
604 | 604 | $post['post_title'] = $data[0]['name']; |
605 | 605 | $post['post_status'] = 'publish'; |
606 | - $post['post_name'] = wp_unique_post_slug(sanitize_title($data[0]['name']),$id, 'draft', 'accommodation', 0); |
|
606 | + $post['post_name'] = wp_unique_post_slug(sanitize_title($data[0]['name']), $id, 'draft', 'accommodation', 0); |
|
607 | 607 | } |
608 | 608 | $id = wp_update_post($post); |
609 | - $prev_date = get_post_meta($id,'lsx_wetu_modified_date',true); |
|
610 | - update_post_meta($id,'lsx_wetu_modified_date',strtotime($data[0]['last_modified']),$prev_date); |
|
611 | - }else{ |
|
609 | + $prev_date = get_post_meta($id, 'lsx_wetu_modified_date', true); |
|
610 | + update_post_meta($id, 'lsx_wetu_modified_date', strtotime($data[0]['last_modified']), $prev_date); |
|
611 | + }else { |
|
612 | 612 | |
613 | 613 | //Set the name |
614 | - if(isset($data[0]['name'])){ |
|
615 | - $post_name = wp_unique_post_slug(sanitize_title($data[0]['name']),$id, 'draft', 'accommodation', 0); |
|
614 | + if (isset($data[0]['name'])) { |
|
615 | + $post_name = wp_unique_post_slug(sanitize_title($data[0]['name']), $id, 'draft', 'accommodation', 0); |
|
616 | 616 | } |
617 | 617 | $post['post_name'] = $post_name; |
618 | 618 | $post['post_title'] = $data[0]['name']; |
@@ -620,90 +620,90 @@ discard block |
||
620 | 620 | $id = wp_insert_post($post); |
621 | 621 | |
622 | 622 | //Save the WETU ID and the Last date it was modified. |
623 | - if(false !== $id){ |
|
624 | - add_post_meta($id,'lsx_wetu_id',$wetu_id); |
|
625 | - add_post_meta($id,'lsx_wetu_modified_date',strtotime($data[0]['last_modified'])); |
|
623 | + if (false !== $id) { |
|
624 | + add_post_meta($id, 'lsx_wetu_id', $wetu_id); |
|
625 | + add_post_meta($id, 'lsx_wetu_modified_date', strtotime($data[0]['last_modified'])); |
|
626 | 626 | } |
627 | 627 | } |
628 | 628 | //Setup some default for use in the import |
629 | - if(false !== $importable_content && (in_array('gallery',$importable_content) || in_array('banner_image',$importable_content) || in_array('featured_image',$importable_content))){ |
|
629 | + if (false !== $importable_content && (in_array('gallery', $importable_content) || in_array('banner_image', $importable_content) || in_array('featured_image', $importable_content))) { |
|
630 | 630 | $this->find_attachments($id); |
631 | 631 | } |
632 | 632 | |
633 | 633 | //Set the team member if it is there |
634 | - if(post_type_exists('team') && false !== $team_members && '' !== $team_members){ |
|
635 | - $this->set_team_member($id,$team_members); |
|
634 | + if (post_type_exists('team') && false !== $team_members && '' !== $team_members) { |
|
635 | + $this->set_team_member($id, $team_members); |
|
636 | 636 | } |
637 | 637 | |
638 | 638 | //Set the safari brand |
639 | - if(false !== $safari_brands && '' !== $safari_brands){ |
|
640 | - $this->set_safari_brands($id,$safari_brands); |
|
639 | + if (false !== $safari_brands && '' !== $safari_brands) { |
|
640 | + $this->set_safari_brands($id, $safari_brands); |
|
641 | 641 | |
642 | 642 | } |
643 | 643 | |
644 | - if(class_exists('LSX_TO_Maps')){ |
|
645 | - $this->set_map_data($data,$id,9); |
|
646 | - $this->set_location_taxonomy($data,$id); |
|
644 | + if (class_exists('LSX_TO_Maps')) { |
|
645 | + $this->set_map_data($data, $id, 9); |
|
646 | + $this->set_location_taxonomy($data, $id); |
|
647 | 647 | } |
648 | 648 | |
649 | - if(post_type_exists('destination') && false !== $importable_content && in_array('destination',$importable_content)){ |
|
650 | - $this->connect_destinations($data,$id); |
|
649 | + if (post_type_exists('destination') && false !== $importable_content && in_array('destination', $importable_content)) { |
|
650 | + $this->connect_destinations($data, $id); |
|
651 | 651 | } |
652 | 652 | |
653 | - if(false !== $importable_content && in_array('category',$importable_content)){ |
|
654 | - $this->set_taxonomy_style($data,$id); |
|
653 | + if (false !== $importable_content && in_array('category', $importable_content)) { |
|
654 | + $this->set_taxonomy_style($data, $id); |
|
655 | 655 | } |
656 | 656 | |
657 | 657 | //Set the Room Data |
658 | - if(false !== $importable_content && in_array('rooms',$importable_content)){ |
|
659 | - $this->set_room_data($data,$id); |
|
658 | + if (false !== $importable_content && in_array('rooms', $importable_content)) { |
|
659 | + $this->set_room_data($data, $id); |
|
660 | 660 | } |
661 | 661 | |
662 | 662 | //Set the rating |
663 | - if(false !== $importable_content && in_array('rating',$importable_content)){ |
|
664 | - $this->set_rating($data,$id); |
|
663 | + if (false !== $importable_content && in_array('rating', $importable_content)) { |
|
664 | + $this->set_rating($data, $id); |
|
665 | 665 | } |
666 | 666 | |
667 | 667 | //Set the checkin checkout data |
668 | - if(false !== $importable_content && in_array('checkin',$importable_content)){ |
|
669 | - $this->set_checkin_checkout($data,$id); |
|
668 | + if (false !== $importable_content && in_array('checkin', $importable_content)) { |
|
669 | + $this->set_checkin_checkout($data, $id); |
|
670 | 670 | } |
671 | 671 | |
672 | 672 | //Set the Spoken Languages |
673 | - if(false !== $importable_content && in_array('spoken_languages',$importable_content)){ |
|
674 | - $this->set_spoken_languages($data,$id); |
|
673 | + if (false !== $importable_content && in_array('spoken_languages', $importable_content)) { |
|
674 | + $this->set_spoken_languages($data, $id); |
|
675 | 675 | } |
676 | 676 | |
677 | 677 | //Set the friendly options |
678 | - if(false !== $importable_content && in_array('friendly',$importable_content)){ |
|
679 | - $this->set_friendly($data,$id); |
|
678 | + if (false !== $importable_content && in_array('friendly', $importable_content)) { |
|
679 | + $this->set_friendly($data, $id); |
|
680 | 680 | } |
681 | 681 | |
682 | 682 | //Set the special_interests |
683 | - if(false !== $importable_content && in_array('special_interests',$importable_content)){ |
|
684 | - $this->set_special_interests($data,$id); |
|
683 | + if (false !== $importable_content && in_array('special_interests', $importable_content)) { |
|
684 | + $this->set_special_interests($data, $id); |
|
685 | 685 | } |
686 | 686 | |
687 | 687 | //Import the videos |
688 | - if(false !== $importable_content && in_array('videos',$importable_content)){ |
|
689 | - $this->set_video_data($data,$id); |
|
688 | + if (false !== $importable_content && in_array('videos', $importable_content)) { |
|
689 | + $this->set_video_data($data, $id); |
|
690 | 690 | } |
691 | 691 | |
692 | 692 | //Import the facilities |
693 | - if(false !== $importable_content && in_array('facilities',$importable_content)){ |
|
694 | - $this->set_facilities($data,$id); |
|
693 | + if (false !== $importable_content && in_array('facilities', $importable_content)) { |
|
694 | + $this->set_facilities($data, $id); |
|
695 | 695 | } |
696 | 696 | |
697 | 697 | //Set the featured image |
698 | - if(false !== $importable_content && in_array('featured_image',$importable_content)){ |
|
699 | - $this->set_featured_image($data,$id); |
|
698 | + if (false !== $importable_content && in_array('featured_image', $importable_content)) { |
|
699 | + $this->set_featured_image($data, $id); |
|
700 | 700 | } |
701 | - if(false !== $importable_content && in_array('banner_image',$importable_content)){ |
|
702 | - $this->set_banner_image($data,$id); |
|
701 | + if (false !== $importable_content && in_array('banner_image', $importable_content)) { |
|
702 | + $this->set_banner_image($data, $id); |
|
703 | 703 | } |
704 | 704 | //Import the main gallery |
705 | - if(false !== $importable_content && in_array('gallery',$importable_content)){ |
|
706 | - $this->create_main_gallery($data,$id); |
|
705 | + if (false !== $importable_content && in_array('gallery', $importable_content)) { |
|
706 | + $this->create_main_gallery($data, $id); |
|
707 | 707 | } |
708 | 708 | } |
709 | 709 | return $id; |
@@ -712,115 +712,115 @@ discard block |
||
712 | 712 | /** |
713 | 713 | * Set the team memberon each item. |
714 | 714 | */ |
715 | - public function set_team_member($id,$team_members) { |
|
715 | + public function set_team_member($id, $team_members) { |
|
716 | 716 | |
717 | 717 | delete_post_meta($id, 'team_to_'.$this->tab_slug); |
718 | - foreach($team_members as $team){ |
|
719 | - add_post_meta($id,'team_to_'.$this->tab_slug,$team); |
|
718 | + foreach ($team_members as $team) { |
|
719 | + add_post_meta($id, 'team_to_'.$this->tab_slug, $team); |
|
720 | 720 | } |
721 | 721 | } |
722 | 722 | |
723 | 723 | /** |
724 | 724 | * Set the safari brand |
725 | 725 | */ |
726 | - public function set_safari_brands($id,$safari_brands) { |
|
727 | - foreach($safari_brands as $safari_brand){ |
|
728 | - wp_set_object_terms( $id, intval($safari_brand), 'accommodation-brand',true); |
|
726 | + public function set_safari_brands($id, $safari_brands) { |
|
727 | + foreach ($safari_brands as $safari_brand) { |
|
728 | + wp_set_object_terms($id, intval($safari_brand), 'accommodation-brand', true); |
|
729 | 729 | } |
730 | 730 | } |
731 | 731 | |
732 | 732 | /** |
733 | 733 | * Saves the longitude and lattitude, as well as sets the map marker. |
734 | 734 | */ |
735 | - public function set_map_data($data,$id,$zoom = '10') { |
|
735 | + public function set_map_data($data, $id, $zoom = '10') { |
|
736 | 736 | $longitude = $latitude = $address = false; |
737 | 737 | |
738 | - if(isset($data[0]['position'])){ |
|
738 | + if (isset($data[0]['position'])) { |
|
739 | 739 | |
740 | - if(isset($data[0]['position']['driving_latitude'])){ |
|
740 | + if (isset($data[0]['position']['driving_latitude'])) { |
|
741 | 741 | $latitude = $data[0]['position']['driving_latitude']; |
742 | - }elseif(isset($data[0]['position']['latitude'])){ |
|
742 | + }elseif (isset($data[0]['position']['latitude'])) { |
|
743 | 743 | $latitude = $data[0]['position']['latitude']; |
744 | 744 | } |
745 | 745 | |
746 | - if(isset($data[0]['position']['driving_longitude'])){ |
|
746 | + if (isset($data[0]['position']['driving_longitude'])) { |
|
747 | 747 | $longitude = $data[0]['position']['driving_longitude']; |
748 | - }elseif(isset($data[0]['position']['longitude'])){ |
|
748 | + }elseif (isset($data[0]['position']['longitude'])) { |
|
749 | 749 | $longitude = $data[0]['position']['longitude']; |
750 | 750 | } |
751 | 751 | |
752 | 752 | } |
753 | - if(isset($data[0]['content']) && isset($data[0]['content']['contact_information'])){ |
|
754 | - if(isset($data[0]['content']['contact_information']['address'])){ |
|
753 | + if (isset($data[0]['content']) && isset($data[0]['content']['contact_information'])) { |
|
754 | + if (isset($data[0]['content']['contact_information']['address'])) { |
|
755 | 755 | $address = strip_tags($data[0]['content']['contact_information']['address']); |
756 | 756 | |
757 | - $address = explode("\n",$address); |
|
758 | - foreach($address as $bitkey => $bit){ |
|
757 | + $address = explode("\n", $address); |
|
758 | + foreach ($address as $bitkey => $bit) { |
|
759 | 759 | $bit = ltrim(rtrim($bit)); |
760 | - if(false === $bit || '' === $bit || null === $bit or empty($bit)){ |
|
760 | + if (false === $bit || '' === $bit || null === $bit or empty($bit)) { |
|
761 | 761 | unset($address[$bitkey]); |
762 | 762 | } |
763 | 763 | } |
764 | - $address = implode(', ',$address); |
|
764 | + $address = implode(', ', $address); |
|
765 | 765 | $address = str_replace(', , ', ', ', $address); |
766 | 766 | } |
767 | 767 | } |
768 | 768 | |
769 | - if(false !== $longitude){ |
|
769 | + if (false !== $longitude) { |
|
770 | 770 | $location_data = array( |
771 | - 'address' => (string)$address, |
|
772 | - 'lat' => (string)$latitude, |
|
773 | - 'long' => (string)$longitude, |
|
774 | - 'zoom' => (string)$zoom, |
|
771 | + 'address' => (string) $address, |
|
772 | + 'lat' => (string) $latitude, |
|
773 | + 'long' => (string) $longitude, |
|
774 | + 'zoom' => (string) $zoom, |
|
775 | 775 | 'elevation' => '', |
776 | 776 | ); |
777 | - if(false !== $id && '0' !== $id){ |
|
778 | - $prev = get_post_meta($id,'location',true); |
|
779 | - update_post_meta($id,'location',$location_data,$prev); |
|
780 | - }else{ |
|
781 | - add_post_meta($id,'location',$location_data,true); |
|
777 | + if (false !== $id && '0' !== $id) { |
|
778 | + $prev = get_post_meta($id, 'location', true); |
|
779 | + update_post_meta($id, 'location', $location_data, $prev); |
|
780 | + }else { |
|
781 | + add_post_meta($id, 'location', $location_data, true); |
|
782 | 782 | } |
783 | 783 | } |
784 | 784 | } |
785 | 785 | /** |
786 | 786 | * Saves the longitude and lattitude, as well as sets the map marker. |
787 | 787 | */ |
788 | - public function set_location_taxonomy($data,$id) { |
|
788 | + public function set_location_taxonomy($data, $id) { |
|
789 | 789 | $taxonomy = 'location'; |
790 | 790 | $terms = false; |
791 | - if(isset($data[0]['position'])){ |
|
791 | + if (isset($data[0]['position'])) { |
|
792 | 792 | $country_id = 0; |
793 | - if(isset($data[0]['position']['country'])){ |
|
793 | + if (isset($data[0]['position']['country'])) { |
|
794 | 794 | |
795 | - if(!$term = term_exists(trim($data[0]['position']['country']), 'location')) |
|
795 | + if (!$term = term_exists(trim($data[0]['position']['country']), 'location')) |
|
796 | 796 | { |
797 | 797 | $term = wp_insert_term(trim($data[0]['position']['country']), 'location'); |
798 | - if ( is_wp_error($term) ){ |
|
798 | + if (is_wp_error($term)) { |
|
799 | 799 | echo $term->get_error_message(); |
800 | 800 | } |
801 | 801 | else { |
802 | - wp_set_object_terms( $id, intval($term['term_id']), 'location',true); |
|
802 | + wp_set_object_terms($id, intval($term['term_id']), 'location', true); |
|
803 | 803 | } |
804 | 804 | } |
805 | 805 | else |
806 | 806 | { |
807 | - wp_set_object_terms( $id, intval($term['term_id']), 'location',true); |
|
807 | + wp_set_object_terms($id, intval($term['term_id']), 'location', true); |
|
808 | 808 | } |
809 | 809 | $country_id = intval($term['term_id']); |
810 | 810 | } |
811 | 811 | |
812 | - if(isset($data[0]['position']['destination'])){ |
|
812 | + if (isset($data[0]['position']['destination'])) { |
|
813 | 813 | |
814 | 814 | $tax_args = array('parent'=>$country_id); |
815 | - if(!$term = term_exists(trim($data[0]['position']['destination']), 'location')) |
|
815 | + if (!$term = term_exists(trim($data[0]['position']['destination']), 'location')) |
|
816 | 816 | { |
817 | 817 | $term = wp_insert_term(trim($data[0]['position']['destination']), 'location', $tax_args); |
818 | - if ( is_wp_error($term) ){echo $term->get_error_message();} |
|
819 | - else { wp_set_object_terms( $id, intval($term['term_id']), 'location',true); } |
|
818 | + if (is_wp_error($term)) {echo $term->get_error_message(); } |
|
819 | + else { wp_set_object_terms($id, intval($term['term_id']), 'location', true); } |
|
820 | 820 | } |
821 | 821 | else |
822 | 822 | { |
823 | - wp_set_object_terms( $id, intval($term['term_id']), 'location',true); |
|
823 | + wp_set_object_terms($id, intval($term['term_id']), 'location', true); |
|
824 | 824 | } |
825 | 825 | } |
826 | 826 | } |
@@ -829,30 +829,30 @@ discard block |
||
829 | 829 | /** |
830 | 830 | * Connects the destinations post type |
831 | 831 | */ |
832 | - public function connect_destinations($data,$id) { |
|
833 | - if(isset($data[0]['position'])){ |
|
832 | + public function connect_destinations($data, $id) { |
|
833 | + if (isset($data[0]['position'])) { |
|
834 | 834 | $destinations = false; |
835 | - if(isset($data[0]['position']['country'])){ |
|
835 | + if (isset($data[0]['position']['country'])) { |
|
836 | 836 | $destinations['country'] = $data[0]['position']['country']; |
837 | 837 | } |
838 | - if(isset($data[0]['position']['destination'])){ |
|
838 | + if (isset($data[0]['position']['destination'])) { |
|
839 | 839 | $destinations['destination'] = $data[0]['position']['destination']; |
840 | 840 | } |
841 | 841 | |
842 | - if(false !== $destinations){ |
|
843 | - $prev_values = get_post_meta($id,'destination_to_accommodation',false); |
|
844 | - if(false === $prev_values || !is_array($prev_values)){ |
|
842 | + if (false !== $destinations) { |
|
843 | + $prev_values = get_post_meta($id, 'destination_to_accommodation', false); |
|
844 | + if (false === $prev_values || !is_array($prev_values)) { |
|
845 | 845 | $prev_values = array(); |
846 | 846 | } |
847 | 847 | //print_r($destinations); |
848 | 848 | $destinations = array_unique($destinations); |
849 | 849 | //print_r($destinations); |
850 | - foreach($destinations as $key => $value){ |
|
850 | + foreach ($destinations as $key => $value) { |
|
851 | 851 | $destination = get_page_by_title(ltrim(rtrim($value)), 'OBJECT', 'destination'); |
852 | 852 | if (null !== $destination) { |
853 | - if(!in_array($destination->ID,$prev_values)){ |
|
854 | - add_post_meta($id,'destination_to_accommodation',$destination->ID,false); |
|
855 | - add_post_meta($destination->ID,'accommodation_to_destination',$id,false); |
|
853 | + if (!in_array($destination->ID, $prev_values)) { |
|
854 | + add_post_meta($id, 'destination_to_accommodation', $destination->ID, false); |
|
855 | + add_post_meta($destination->ID, 'accommodation_to_destination', $id, false); |
|
856 | 856 | $this->cleanup_posts[$destination->ID] = 'accommodation_to_destination'; |
857 | 857 | } |
858 | 858 | } |
@@ -864,18 +864,18 @@ discard block |
||
864 | 864 | /** |
865 | 865 | * Set the Travel Style |
866 | 866 | */ |
867 | - public function set_taxonomy_style($data,$id) { |
|
867 | + public function set_taxonomy_style($data, $id) { |
|
868 | 868 | $terms = false; |
869 | - if(isset($data[0]['category'])){ |
|
870 | - if(!$term = term_exists(trim($data[0]['category']), 'accommodation-type')) |
|
869 | + if (isset($data[0]['category'])) { |
|
870 | + if (!$term = term_exists(trim($data[0]['category']), 'accommodation-type')) |
|
871 | 871 | { |
872 | 872 | $term = wp_insert_term(trim($data[0]['category']), 'accommodation-type'); |
873 | - if ( is_wp_error($term) ){echo $term->get_error_message();} |
|
874 | - else { wp_set_object_terms( $id, intval($term['term_id']), 'accommodation-type',true); } |
|
873 | + if (is_wp_error($term)) {echo $term->get_error_message(); } |
|
874 | + else { wp_set_object_terms($id, intval($term['term_id']), 'accommodation-type', true); } |
|
875 | 875 | } |
876 | 876 | else |
877 | 877 | { |
878 | - wp_set_object_terms( $id, intval($term['term_id']), 'accommodation-type',true); |
|
878 | + wp_set_object_terms($id, intval($term['term_id']), 'accommodation-type', true); |
|
879 | 879 | } |
880 | 880 | } |
881 | 881 | } |
@@ -883,23 +883,23 @@ discard block |
||
883 | 883 | /** |
884 | 884 | * Saves the room data |
885 | 885 | */ |
886 | - public function set_room_data($data,$id) { |
|
887 | - if(!empty($data[0]['rooms']) && is_array($data[0]['rooms'])){ |
|
886 | + public function set_room_data($data, $id) { |
|
887 | + if (!empty($data[0]['rooms']) && is_array($data[0]['rooms'])) { |
|
888 | 888 | $rooms = false; |
889 | 889 | |
890 | - foreach($data[0]['rooms'] as $room){ |
|
890 | + foreach ($data[0]['rooms'] as $room) { |
|
891 | 891 | |
892 | 892 | $temp_room = array(); |
893 | - if(isset($room['name'])){ |
|
893 | + if (isset($room['name'])) { |
|
894 | 894 | $temp_room['title'] = $room['name']; |
895 | 895 | } |
896 | - if(isset($room['description'])){ |
|
896 | + if (isset($room['description'])) { |
|
897 | 897 | $temp_room['description'] = strip_tags($room['description']); |
898 | 898 | } |
899 | 899 | $temp_room['price'] = 0; |
900 | 900 | $temp_room['type'] = 'room'; |
901 | 901 | |
902 | - if(!empty($room['images']) && is_array($room['images'])){ |
|
902 | + if (!empty($room['images']) && is_array($room['images'])) { |
|
903 | 903 | $attachments_args = array( |
904 | 904 | 'post_parent' => $id, |
905 | 905 | 'post_status' => 'inherit', |
@@ -909,38 +909,38 @@ discard block |
||
909 | 909 | $attachments = new WP_Query($attachments_args); |
910 | 910 | $found_attachments = array(); |
911 | 911 | |
912 | - if($attachments->have_posts()){ |
|
913 | - foreach($attachments->posts as $attachment){ |
|
914 | - $found_attachments[] = str_replace(array('.jpg','.png','.jpeg'),'',$attachment->post_title); |
|
912 | + if ($attachments->have_posts()) { |
|
913 | + foreach ($attachments->posts as $attachment) { |
|
914 | + $found_attachments[] = str_replace(array('.jpg', '.png', '.jpeg'), '', $attachment->post_title); |
|
915 | 915 | } |
916 | 916 | } |
917 | 917 | |
918 | 918 | $temp_room['gallery'] = array(); |
919 | - foreach($room['images'] as $image_data){ |
|
920 | - $temp_room['gallery'][] = $this->attach_image($image_data,$id,$found_attachments); |
|
919 | + foreach ($room['images'] as $image_data) { |
|
920 | + $temp_room['gallery'][] = $this->attach_image($image_data, $id, $found_attachments); |
|
921 | 921 | } |
922 | 922 | } |
923 | 923 | $rooms[] = $temp_room; |
924 | 924 | } |
925 | 925 | |
926 | - if(false !== $id && '0' !== $id){ |
|
926 | + if (false !== $id && '0' !== $id) { |
|
927 | 927 | delete_post_meta($id, 'units'); |
928 | 928 | } |
929 | - foreach($rooms as $room){ |
|
930 | - add_post_meta($id,'units',$room,false); |
|
929 | + foreach ($rooms as $room) { |
|
930 | + add_post_meta($id, 'units', $room, false); |
|
931 | 931 | } |
932 | 932 | |
933 | - if(isset($data[0]['features']) && isset($data[0]['features']['rooms'])){ |
|
933 | + if (isset($data[0]['features']) && isset($data[0]['features']['rooms'])) { |
|
934 | 934 | $room_count = $data[0]['features']['rooms']; |
935 | - }else{ |
|
935 | + }else { |
|
936 | 936 | $room_count = count($data[0]['rooms']); |
937 | 937 | } |
938 | 938 | |
939 | - if(false !== $id && '0' !== $id){ |
|
940 | - $prev_rooms = get_post_meta($id,'number_of_rooms',true); |
|
941 | - update_post_meta($id,'number_of_rooms',$room_count,$prev_rooms); |
|
942 | - }else{ |
|
943 | - add_post_meta($id,'number_of_rooms',$room_count,true); |
|
939 | + if (false !== $id && '0' !== $id) { |
|
940 | + $prev_rooms = get_post_meta($id, 'number_of_rooms', true); |
|
941 | + update_post_meta($id, 'number_of_rooms', $room_count, $prev_rooms); |
|
942 | + }else { |
|
943 | + add_post_meta($id, 'number_of_rooms', $room_count, true); |
|
944 | 944 | } |
945 | 945 | } |
946 | 946 | } |
@@ -948,31 +948,31 @@ discard block |
||
948 | 948 | /** |
949 | 949 | * Set the ratings |
950 | 950 | */ |
951 | - public function set_rating($data,$id) { |
|
951 | + public function set_rating($data, $id) { |
|
952 | 952 | |
953 | - if(!empty($data[0]['features']) && isset($data[0]['features']['star_authority'])){ |
|
953 | + if (!empty($data[0]['features']) && isset($data[0]['features']['star_authority'])) { |
|
954 | 954 | $rating_type = $data[0]['features']['star_authority']; |
955 | - }else{ |
|
955 | + }else { |
|
956 | 956 | $rating_type = 'Unspecified2'; |
957 | 957 | } |
958 | - $this->save_custom_field($rating_type,'rating_type',$id); |
|
958 | + $this->save_custom_field($rating_type, 'rating_type', $id); |
|
959 | 959 | |
960 | - if(!empty($data[0]['features']) && isset($data[0]['features']['stars'])){ |
|
961 | - $this->save_custom_field($data[0]['features']['stars'],'rating',$id,true); |
|
960 | + if (!empty($data[0]['features']) && isset($data[0]['features']['stars'])) { |
|
961 | + $this->save_custom_field($data[0]['features']['stars'], 'rating', $id, true); |
|
962 | 962 | } |
963 | 963 | } |
964 | 964 | |
965 | 965 | /** |
966 | 966 | * Set the spoken_languages |
967 | 967 | */ |
968 | - public function set_spoken_languages($data,$id) { |
|
969 | - if(!empty($data[0]['features']) && isset($data[0]['features']['spoken_languages']) && !empty($data[0]['features']['spoken_languages'])){ |
|
968 | + public function set_spoken_languages($data, $id) { |
|
969 | + if (!empty($data[0]['features']) && isset($data[0]['features']['spoken_languages']) && !empty($data[0]['features']['spoken_languages'])) { |
|
970 | 970 | $languages = false; |
971 | - foreach($data[0]['features']['spoken_languages'] as $spoken_language){ |
|
971 | + foreach ($data[0]['features']['spoken_languages'] as $spoken_language) { |
|
972 | 972 | $languages[] = sanitize_title($spoken_language); |
973 | 973 | } |
974 | - if(false !== $languages){ |
|
975 | - $this->save_custom_field($languages,'spoken_languages',$id); |
|
974 | + if (false !== $languages) { |
|
975 | + $this->save_custom_field($languages, 'spoken_languages', $id); |
|
976 | 976 | } |
977 | 977 | } |
978 | 978 | } |
@@ -980,14 +980,14 @@ discard block |
||
980 | 980 | /** |
981 | 981 | * Set the friendly |
982 | 982 | */ |
983 | - public function set_friendly($data,$id) { |
|
984 | - if(!empty($data[0]['features']) && isset($data[0]['features']['suggested_visitor_types']) && !empty($data[0]['features']['suggested_visitor_types'])){ |
|
983 | + public function set_friendly($data, $id) { |
|
984 | + if (!empty($data[0]['features']) && isset($data[0]['features']['suggested_visitor_types']) && !empty($data[0]['features']['suggested_visitor_types'])) { |
|
985 | 985 | $friendly_options = false; |
986 | - foreach($data[0]['features']['suggested_visitor_types'] as $visitor_type){ |
|
986 | + foreach ($data[0]['features']['suggested_visitor_types'] as $visitor_type) { |
|
987 | 987 | $friendly_options[] = sanitize_title($visitor_type); |
988 | 988 | } |
989 | - if(false !== $friendly_options){ |
|
990 | - $this->save_custom_field($friendly_options,'suggested_visitor_types',$id); |
|
989 | + if (false !== $friendly_options) { |
|
990 | + $this->save_custom_field($friendly_options, 'suggested_visitor_types', $id); |
|
991 | 991 | } |
992 | 992 | } |
993 | 993 | } |
@@ -995,14 +995,14 @@ discard block |
||
995 | 995 | /** |
996 | 996 | * Set the special interests |
997 | 997 | */ |
998 | - public function set_special_interests($data,$id) { |
|
999 | - if(!empty($data[0]['features']) && isset($data[0]['features']['special_interests']) && !empty($data[0]['features']['special_interests'])){ |
|
998 | + public function set_special_interests($data, $id) { |
|
999 | + if (!empty($data[0]['features']) && isset($data[0]['features']['special_interests']) && !empty($data[0]['features']['special_interests'])) { |
|
1000 | 1000 | $interests = false; |
1001 | - foreach($data[0]['features']['special_interests'] as $special_interest){ |
|
1001 | + foreach ($data[0]['features']['special_interests'] as $special_interest) { |
|
1002 | 1002 | $interests[] = sanitize_title($special_interest); |
1003 | 1003 | } |
1004 | - if(false !== $interests){ |
|
1005 | - $this->save_custom_field($interests,'special_interests',$id); |
|
1004 | + if (false !== $interests) { |
|
1005 | + $this->save_custom_field($interests, 'special_interests', $id); |
|
1006 | 1006 | } |
1007 | 1007 | } |
1008 | 1008 | } |
@@ -1010,48 +1010,48 @@ discard block |
||
1010 | 1010 | /** |
1011 | 1011 | * Set the Check in and Check out Date |
1012 | 1012 | */ |
1013 | - public function set_checkin_checkout($data,$id) { |
|
1013 | + public function set_checkin_checkout($data, $id) { |
|
1014 | 1014 | |
1015 | - if(!empty($data[0]['features']) && isset($data[0]['features']['check_in_time'])){ |
|
1016 | - $time = str_replace('h',':',$data[0]['features']['check_in_time']); |
|
1017 | - $time = date('h:ia',strtotime($time)); |
|
1018 | - $this->save_custom_field($time,'checkin_time',$id); |
|
1015 | + if (!empty($data[0]['features']) && isset($data[0]['features']['check_in_time'])) { |
|
1016 | + $time = str_replace('h', ':', $data[0]['features']['check_in_time']); |
|
1017 | + $time = date('h:ia', strtotime($time)); |
|
1018 | + $this->save_custom_field($time, 'checkin_time', $id); |
|
1019 | 1019 | } |
1020 | - if(!empty($data[0]['features']) && isset($data[0]['features']['check_out_time'])){ |
|
1021 | - $time = str_replace('h',':',$data[0]['features']['check_out_time']); |
|
1022 | - $time = date('h:ia',strtotime($time)); |
|
1023 | - $this->save_custom_field($time,'checkout_time',$id); |
|
1020 | + if (!empty($data[0]['features']) && isset($data[0]['features']['check_out_time'])) { |
|
1021 | + $time = str_replace('h', ':', $data[0]['features']['check_out_time']); |
|
1022 | + $time = date('h:ia', strtotime($time)); |
|
1023 | + $this->save_custom_field($time, 'checkout_time', $id); |
|
1024 | 1024 | } |
1025 | 1025 | } |
1026 | 1026 | |
1027 | 1027 | /** |
1028 | 1028 | * Set the Video date |
1029 | 1029 | */ |
1030 | - public function set_video_data($data,$id) { |
|
1031 | - if(!empty($data[0]['content']['youtube_videos']) && is_array($data[0]['content']['youtube_videos'])){ |
|
1030 | + public function set_video_data($data, $id) { |
|
1031 | + if (!empty($data[0]['content']['youtube_videos']) && is_array($data[0]['content']['youtube_videos'])) { |
|
1032 | 1032 | $videos = false; |
1033 | 1033 | |
1034 | - foreach($data[0]['content']['youtube_videos'] as $video){ |
|
1034 | + foreach ($data[0]['content']['youtube_videos'] as $video) { |
|
1035 | 1035 | $temp_video = array(); |
1036 | 1036 | |
1037 | - if(isset($video['label'])){ |
|
1037 | + if (isset($video['label'])) { |
|
1038 | 1038 | $temp_video['title'] = $video['label']; |
1039 | 1039 | } |
1040 | - if(isset($video['description'])){ |
|
1040 | + if (isset($video['description'])) { |
|
1041 | 1041 | $temp_video['description'] = strip_tags($video['description']); |
1042 | 1042 | } |
1043 | - if(isset($video['url'])){ |
|
1043 | + if (isset($video['url'])) { |
|
1044 | 1044 | $temp_video['url'] = $video['url']; |
1045 | 1045 | } |
1046 | 1046 | $temp_video['thumbnail'] = ''; |
1047 | 1047 | $videos[] = $temp_video; |
1048 | 1048 | } |
1049 | 1049 | |
1050 | - if(false !== $id && '0' !== $id){ |
|
1050 | + if (false !== $id && '0' !== $id) { |
|
1051 | 1051 | delete_post_meta($id, 'videos'); |
1052 | 1052 | } |
1053 | - foreach($videos as $video){ |
|
1054 | - add_post_meta($id,'videos',$video,false); |
|
1053 | + foreach ($videos as $video) { |
|
1054 | + add_post_meta($id, 'videos', $video, false); |
|
1055 | 1055 | } |
1056 | 1056 | } |
1057 | 1057 | } |
@@ -1059,7 +1059,7 @@ discard block |
||
1059 | 1059 | /** |
1060 | 1060 | * Set the Facilities |
1061 | 1061 | */ |
1062 | - public function set_facilities($data,$id) { |
|
1062 | + public function set_facilities($data, $id) { |
|
1063 | 1063 | |
1064 | 1064 | $parent_facilities = array( |
1065 | 1065 | 'available_services' => 'Available Services', |
@@ -1067,28 +1067,28 @@ discard block |
||
1067 | 1067 | 'room_facilities' => 'Room Facilities', |
1068 | 1068 | 'activities_on_site' => 'Activities on Site' |
1069 | 1069 | ); |
1070 | - foreach($parent_facilities as $key => $label){ |
|
1070 | + foreach ($parent_facilities as $key => $label) { |
|
1071 | 1071 | $terms = false; |
1072 | - if(isset($data[0]['features']) && isset($data[0]['features'][$key])){ |
|
1073 | - $parent_id = $this->set_term($id,$label,'facility'); |
|
1072 | + if (isset($data[0]['features']) && isset($data[0]['features'][$key])) { |
|
1073 | + $parent_id = $this->set_term($id, $label, 'facility'); |
|
1074 | 1074 | } |
1075 | - foreach($data[0]['features'][$key] as $child_facility){ |
|
1076 | - $this->set_term($id,$child_facility,'facility',$parent_id); |
|
1075 | + foreach ($data[0]['features'][$key] as $child_facility) { |
|
1076 | + $this->set_term($id, $child_facility, 'facility', $parent_id); |
|
1077 | 1077 | } |
1078 | 1078 | } |
1079 | 1079 | } |
1080 | 1080 | |
1081 | - function set_term($id=false,$name=false,$taxonomy=false,$parent=false){ |
|
1082 | - if(!$term = term_exists($name, $taxonomy)) |
|
1081 | + function set_term($id = false, $name = false, $taxonomy = false, $parent = false) { |
|
1082 | + if (!$term = term_exists($name, $taxonomy)) |
|
1083 | 1083 | { |
1084 | - if(false !== $parent){ $parent = array('parent'=>$parent); } |
|
1085 | - $term = wp_insert_term(trim($name), $taxonomy,$parent); |
|
1086 | - if ( is_wp_error($term) ){echo $term->get_error_message();} |
|
1087 | - else { wp_set_object_terms( $id, intval($term['term_id']), $taxonomy,true); } |
|
1084 | + if (false !== $parent) { $parent = array('parent'=>$parent); } |
|
1085 | + $term = wp_insert_term(trim($name), $taxonomy, $parent); |
|
1086 | + if (is_wp_error($term)) {echo $term->get_error_message(); } |
|
1087 | + else { wp_set_object_terms($id, intval($term['term_id']), $taxonomy, true); } |
|
1088 | 1088 | } |
1089 | 1089 | else |
1090 | 1090 | { |
1091 | - wp_set_object_terms( $id, intval($term['term_id']), $taxonomy,true); |
|
1091 | + wp_set_object_terms($id, intval($term['term_id']), $taxonomy, true); |
|
1092 | 1092 | } |
1093 | 1093 | return $term['term_id']; |
1094 | 1094 | } |
@@ -1096,16 +1096,16 @@ discard block |
||
1096 | 1096 | /** |
1097 | 1097 | * Creates the main gallery data |
1098 | 1098 | */ |
1099 | - public function set_featured_image($data,$id) { |
|
1100 | - if(is_array($data[0]['content']['images']) && !empty($data[0]['content']['images'])){ |
|
1101 | - $this->featured_image = $this->attach_image($data[0]['content']['images'][0],$id); |
|
1099 | + public function set_featured_image($data, $id) { |
|
1100 | + if (is_array($data[0]['content']['images']) && !empty($data[0]['content']['images'])) { |
|
1101 | + $this->featured_image = $this->attach_image($data[0]['content']['images'][0], $id); |
|
1102 | 1102 | |
1103 | - if(false !== $this->featured_image){ |
|
1104 | - delete_post_meta($id,'_thumbnail_id'); |
|
1105 | - add_post_meta($id,'_thumbnail_id',$this->featured_image,true); |
|
1103 | + if (false !== $this->featured_image) { |
|
1104 | + delete_post_meta($id, '_thumbnail_id'); |
|
1105 | + add_post_meta($id, '_thumbnail_id', $this->featured_image, true); |
|
1106 | 1106 | |
1107 | - if(!empty($this->gallery_meta) && !in_array($this->featured_image,$this->gallery_meta)){ |
|
1108 | - add_post_meta($id,'gallery',$this->featured_image,false); |
|
1107 | + if (!empty($this->gallery_meta) && !in_array($this->featured_image, $this->gallery_meta)) { |
|
1108 | + add_post_meta($id, 'gallery', $this->featured_image, false); |
|
1109 | 1109 | $this->gallery_meta[] = $this->featured_image; |
1110 | 1110 | } |
1111 | 1111 | } |
@@ -1115,17 +1115,17 @@ discard block |
||
1115 | 1115 | /** |
1116 | 1116 | * Sets a banner image |
1117 | 1117 | */ |
1118 | - public function set_banner_image($data,$id) { |
|
1119 | - if(is_array($data[0]['content']['images']) && !empty($data[0]['content']['images'])){ |
|
1120 | - $this->banner_image = $this->attach_image($data[0]['content']['images'][1],$id,array('width'=>'1920','height'=>'800','cropping'=>'c')); |
|
1118 | + public function set_banner_image($data, $id) { |
|
1119 | + if (is_array($data[0]['content']['images']) && !empty($data[0]['content']['images'])) { |
|
1120 | + $this->banner_image = $this->attach_image($data[0]['content']['images'][1], $id, array('width'=>'1920', 'height'=>'800', 'cropping'=>'c')); |
|
1121 | 1121 | |
1122 | - if(false !== $this->banner_image){ |
|
1123 | - delete_post_meta($id,'image_group'); |
|
1122 | + if (false !== $this->banner_image) { |
|
1123 | + delete_post_meta($id, 'image_group'); |
|
1124 | 1124 | $new_banner = array('banner_image'=>array('cmb-field-0'=>$this->banner_image)); |
1125 | - add_post_meta($id,'image_group',$new_banner,true); |
|
1125 | + add_post_meta($id, 'image_group', $new_banner, true); |
|
1126 | 1126 | |
1127 | - if(!empty($this->gallery_meta) && !in_array($this->banner_image,$this->gallery_meta)){ |
|
1128 | - add_post_meta($id,'gallery',$this->banner_image,false); |
|
1127 | + if (!empty($this->gallery_meta) && !in_array($this->banner_image, $this->gallery_meta)) { |
|
1128 | + add_post_meta($id, 'gallery', $this->banner_image, false); |
|
1129 | 1129 | $this->gallery_meta[] = $this->banner_image; |
1130 | 1130 | } |
1131 | 1131 | } |
@@ -1135,24 +1135,24 @@ discard block |
||
1135 | 1135 | /** |
1136 | 1136 | * Creates the main gallery data |
1137 | 1137 | */ |
1138 | - public function create_main_gallery($data,$id) { |
|
1138 | + public function create_main_gallery($data, $id) { |
|
1139 | 1139 | |
1140 | - if(is_array($data[0]['content']['images']) && !empty($data[0]['content']['images'])){ |
|
1140 | + if (is_array($data[0]['content']['images']) && !empty($data[0]['content']['images'])) { |
|
1141 | 1141 | $counter = 0; |
1142 | - foreach($data[0]['content']['images'] as $image_data){ |
|
1143 | - if($counter === 0 && false !== $this->featured_image){$counter++;continue;} |
|
1144 | - if($counter === 1 && false !== $this->banner_image){$counter++;continue;} |
|
1142 | + foreach ($data[0]['content']['images'] as $image_data) { |
|
1143 | + if ($counter === 0 && false !== $this->featured_image) {$counter++; continue; } |
|
1144 | + if ($counter === 1 && false !== $this->banner_image) {$counter++; continue; } |
|
1145 | 1145 | |
1146 | - $this->gallery_meta[] = $this->attach_image($image_data,$id); |
|
1146 | + $this->gallery_meta[] = $this->attach_image($image_data, $id); |
|
1147 | 1147 | $counter++; |
1148 | 1148 | } |
1149 | 1149 | |
1150 | - if(!empty($this->gallery_meta)){ |
|
1151 | - delete_post_meta($id,'gallery'); |
|
1150 | + if (!empty($this->gallery_meta)) { |
|
1151 | + delete_post_meta($id, 'gallery'); |
|
1152 | 1152 | $this->gallery_meta = array_unique($this->gallery_meta); |
1153 | - foreach($this->gallery_meta as $gallery_id){ |
|
1154 | - if(false !== $gallery_id && '' !== $gallery_id && !is_array($gallery_id)){ |
|
1155 | - add_post_meta($id,'gallery',$gallery_id,false); |
|
1153 | + foreach ($this->gallery_meta as $gallery_id) { |
|
1154 | + if (false !== $gallery_id && '' !== $gallery_id && !is_array($gallery_id)) { |
|
1155 | + add_post_meta($id, 'gallery', $gallery_id, false); |
|
1156 | 1156 | } |
1157 | 1157 | } |
1158 | 1158 | } |
@@ -1162,53 +1162,53 @@ discard block |
||
1162 | 1162 | /** |
1163 | 1163 | * Attaches 1 image |
1164 | 1164 | */ |
1165 | - public function attach_image($v=false,$parent_id,$image_sizes=false){ |
|
1166 | - if(false !== $v){ |
|
1167 | - $temp_fragment = explode('/',$v['url_fragment']); |
|
1168 | - $url_filename = $temp_fragment[count($temp_fragment)-1]; |
|
1169 | - $url_filename = str_replace(array('.jpg','.png','.jpeg'),'',$url_filename); |
|
1170 | - |
|
1171 | - if(in_array($url_filename,$this->found_attachments)){ |
|
1172 | - return array_search($url_filename,$this->found_attachments); |
|
1165 | + public function attach_image($v = false, $parent_id, $image_sizes = false) { |
|
1166 | + if (false !== $v) { |
|
1167 | + $temp_fragment = explode('/', $v['url_fragment']); |
|
1168 | + $url_filename = $temp_fragment[count($temp_fragment) - 1]; |
|
1169 | + $url_filename = str_replace(array('.jpg', '.png', '.jpeg'), '', $url_filename); |
|
1170 | + |
|
1171 | + if (in_array($url_filename, $this->found_attachments)) { |
|
1172 | + return array_search($url_filename, $this->found_attachments); |
|
1173 | 1173 | } |
1174 | 1174 | |
1175 | - $postdata=array(); |
|
1176 | - if(empty($v['label'])) |
|
1175 | + $postdata = array(); |
|
1176 | + if (empty($v['label'])) |
|
1177 | 1177 | { |
1178 | - $v['label']=''; |
|
1178 | + $v['label'] = ''; |
|
1179 | 1179 | } |
1180 | - if(!empty($v['description'])) |
|
1180 | + if (!empty($v['description'])) |
|
1181 | 1181 | { |
1182 | - $desc=wp_strip_all_tags($v['description']); |
|
1183 | - $posdata=array('post_excerpt'=>$desc); |
|
1182 | + $desc = wp_strip_all_tags($v['description']); |
|
1183 | + $posdata = array('post_excerpt'=>$desc); |
|
1184 | 1184 | } |
1185 | - if(!empty($v['section'])) |
|
1185 | + if (!empty($v['section'])) |
|
1186 | 1186 | { |
1187 | - $desc=wp_strip_all_tags($v['section']); |
|
1188 | - $posdata=array('post_excerpt'=>$desc); |
|
1187 | + $desc = wp_strip_all_tags($v['section']); |
|
1188 | + $posdata = array('post_excerpt'=>$desc); |
|
1189 | 1189 | } |
1190 | 1190 | |
1191 | - $attachID=NULL; |
|
1191 | + $attachID = NULL; |
|
1192 | 1192 | //Resizor - add option to setting if required |
1193 | - $fragment = str_replace(' ','%20',$v['url_fragment']); |
|
1193 | + $fragment = str_replace(' ', '%20', $v['url_fragment']); |
|
1194 | 1194 | $url = $this->get_scaling_url($image_sizes).$fragment; |
1195 | - $attachID = $this->attach_external_image2($url,$parent_id,'',$v['label'],$postdata); |
|
1195 | + $attachID = $this->attach_external_image2($url, $parent_id, '', $v['label'], $postdata); |
|
1196 | 1196 | |
1197 | 1197 | //echo($attachID.' add image'); |
1198 | - if($attachID!=NULL) |
|
1198 | + if ($attachID != NULL) |
|
1199 | 1199 | { |
1200 | 1200 | return $attachID; |
1201 | 1201 | } |
1202 | 1202 | } |
1203 | 1203 | return false; |
1204 | 1204 | } |
1205 | - public function attach_external_image2( $url = null, $post_id = null, $thumb = null, $filename = null, $post_data = array() ) { |
|
1205 | + public function attach_external_image2($url = null, $post_id = null, $thumb = null, $filename = null, $post_data = array()) { |
|
1206 | 1206 | |
1207 | - if ( !$url || !$post_id ) { return new WP_Error('missing', "Need a valid URL and post ID..."); } |
|
1207 | + if (!$url || !$post_id) { return new WP_Error('missing', "Need a valid URL and post ID..."); } |
|
1208 | 1208 | |
1209 | - require_once(ABSPATH . 'wp-admin/includes/file.php'); |
|
1210 | - require_once(ABSPATH . 'wp-admin/includes/media.php'); |
|
1211 | - require_once(ABSPATH . 'wp-admin/includes/image.php'); |
|
1209 | + require_once(ABSPATH.'wp-admin/includes/file.php'); |
|
1210 | + require_once(ABSPATH.'wp-admin/includes/media.php'); |
|
1211 | + require_once(ABSPATH.'wp-admin/includes/image.php'); |
|
1212 | 1212 | // Download file to temp location, returns full server path to temp file |
1213 | 1213 | //$tmp = download_url( $url ); |
1214 | 1214 | |
@@ -1217,53 +1217,53 @@ discard block |
||
1217 | 1217 | |
1218 | 1218 | $image = file_get_contents($url); |
1219 | 1219 | file_put_contents($tmp, $image); |
1220 | - chmod($tmp,'777'); |
|
1220 | + chmod($tmp, '777'); |
|
1221 | 1221 | |
1222 | - preg_match('/[^\?]+\.(tif|TIFF|jpg|JPG|jpe|JPE|jpeg|JPEG|gif|GIF|png|PNG|pdf|PDF|bmp|BMP)/', $url, $matches); // fix file filename for query strings |
|
1222 | + preg_match('/[^\?]+\.(tif|TIFF|jpg|JPG|jpe|JPE|jpeg|JPEG|gif|GIF|png|PNG|pdf|PDF|bmp|BMP)/', $url, $matches); // fix file filename for query strings |
|
1223 | 1223 | $url_filename = basename($matches[0]); |
1224 | - $url_filename=str_replace('%20','_',$url_filename); |
|
1224 | + $url_filename = str_replace('%20', '_', $url_filename); |
|
1225 | 1225 | // extract filename from url for title |
1226 | - $url_type = wp_check_filetype($url_filename); // determine file type (ext and mime/type) |
|
1226 | + $url_type = wp_check_filetype($url_filename); // determine file type (ext and mime/type) |
|
1227 | 1227 | |
1228 | 1228 | // override filename if given, reconstruct server path |
1229 | - if ( !empty( $filename ) && " " != $filename ) |
|
1229 | + if (!empty($filename) && " " != $filename) |
|
1230 | 1230 | { |
1231 | 1231 | $filename = sanitize_file_name($filename); |
1232 | - $tmppath = pathinfo( $tmp ); |
|
1232 | + $tmppath = pathinfo($tmp); |
|
1233 | 1233 | |
1234 | 1234 | $extension = ''; |
1235 | - if(isset($tmppath['extension'])){ |
|
1235 | + if (isset($tmppath['extension'])) { |
|
1236 | 1236 | $extension = $tmppath['extension']; |
1237 | 1237 | } |
1238 | 1238 | |
1239 | - $new = $tmppath['dirname'] . "/". $filename . "." . $extension; |
|
1240 | - rename($tmp, $new); // renames temp file on server |
|
1241 | - $tmp = $new; // push new filename (in path) to be used in file array later |
|
1239 | + $new = $tmppath['dirname']."/".$filename.".".$extension; |
|
1240 | + rename($tmp, $new); // renames temp file on server |
|
1241 | + $tmp = $new; // push new filename (in path) to be used in file array later |
|
1242 | 1242 | } |
1243 | 1243 | |
1244 | 1244 | // assemble file data (should be built like $_FILES since wp_handle_sideload() will be using) |
1245 | - $file_array['tmp_name'] = $tmp; // full server path to temp file |
|
1245 | + $file_array['tmp_name'] = $tmp; // full server path to temp file |
|
1246 | 1246 | |
1247 | - if ( !empty( $filename) && " " != $filename ) |
|
1247 | + if (!empty($filename) && " " != $filename) |
|
1248 | 1248 | { |
1249 | - $file_array['name'] = $filename . "." . $url_type['ext']; // user given filename for title, add original URL extension |
|
1249 | + $file_array['name'] = $filename.".".$url_type['ext']; // user given filename for title, add original URL extension |
|
1250 | 1250 | } |
1251 | 1251 | else |
1252 | 1252 | { |
1253 | - $file_array['name'] = $url_filename; // just use original URL filename |
|
1253 | + $file_array['name'] = $url_filename; // just use original URL filename |
|
1254 | 1254 | } |
1255 | 1255 | |
1256 | 1256 | // set additional wp_posts columns |
1257 | - if ( empty( $post_data['post_title'] ) ) |
|
1257 | + if (empty($post_data['post_title'])) |
|
1258 | 1258 | { |
1259 | 1259 | |
1260 | - $url_filename=str_replace('%20',' ',$url_filename); |
|
1260 | + $url_filename = str_replace('%20', ' ', $url_filename); |
|
1261 | 1261 | |
1262 | - $post_data['post_title'] = basename($url_filename, "." . $url_type['ext']); // just use the original filename (no extension) |
|
1262 | + $post_data['post_title'] = basename($url_filename, ".".$url_type['ext']); // just use the original filename (no extension) |
|
1263 | 1263 | } |
1264 | 1264 | |
1265 | 1265 | // make sure gets tied to parent |
1266 | - if ( empty( $post_data['post_parent'] ) ) |
|
1266 | + if (empty($post_data['post_parent'])) |
|
1267 | 1267 | { |
1268 | 1268 | $post_data['post_parent'] = $post_id; |
1269 | 1269 | } |
@@ -1271,12 +1271,12 @@ discard block |
||
1271 | 1271 | // required libraries for media_handle_sideload |
1272 | 1272 | |
1273 | 1273 | // do the validation and storage stuff |
1274 | - $att_id = media_handle_sideload( $file_array, $post_id, null, $post_data ); // $post_data can override the items saved to wp_posts table, like post_mime_type, guid, post_parent, post_title, post_content, post_status |
|
1274 | + $att_id = media_handle_sideload($file_array, $post_id, null, $post_data); // $post_data can override the items saved to wp_posts table, like post_mime_type, guid, post_parent, post_title, post_content, post_status |
|
1275 | 1275 | |
1276 | 1276 | // If error storing permanently, unlink |
1277 | - if ( is_wp_error($att_id) ) |
|
1277 | + if (is_wp_error($att_id)) |
|
1278 | 1278 | { |
1279 | - unlink($file_array['tmp_name']); // clean up |
|
1279 | + unlink($file_array['tmp_name']); // clean up |
|
1280 | 1280 | return false; // output wp_error |
1281 | 1281 | //return $att_id; // output wp_error |
1282 | 1282 | } |