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