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