@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | */ |
| 71 | 71 | public function set_variables() |
| 72 | 72 | { |
| 73 | - parent::set_variables(); |
|
| 73 | + parent::set_variables(); |
|
| 74 | 74 | // ** This request only works with API KEY ** |
| 75 | 75 | //if ( false !== $this->api_username && false !== $this->api_password ) { |
| 76 | 76 | // $this->url = 'https://wetu.com/API/Pins/'; |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | * Display the importer administration screen |
| 96 | 96 | */ |
| 97 | 97 | public function display_page() { |
| 98 | - ?> |
|
| 98 | + ?> |
|
| 99 | 99 | <div class="wrap"> |
| 100 | 100 | <?php $this->navigation('accommodation'); ?> |
| 101 | 101 | |
@@ -236,8 +236,8 @@ discard block |
||
| 236 | 236 | $accommodation = json_decode($data, true); |
| 237 | 237 | |
| 238 | 238 | if(isset($accommodation['error'])){ |
| 239 | - return $accommodation['error']; |
|
| 240 | - }elseif (isset($accommodation) && !empty($accommodation)) { |
|
| 239 | + return $accommodation['error']; |
|
| 240 | + }elseif (isset($accommodation) && !empty($accommodation)) { |
|
| 241 | 241 | set_transient('lsx_ti_accommodation',$accommodation,60*60*2); |
| 242 | 242 | return true; |
| 243 | 243 | } |
@@ -253,8 +253,8 @@ discard block |
||
| 253 | 253 | $accommodation = get_transient('lsx_ti_accommodation'); |
| 254 | 254 | |
| 255 | 255 | if(false === $accommodation){ |
| 256 | - $this->update_options(); |
|
| 257 | - } |
|
| 256 | + $this->update_options(); |
|
| 257 | + } |
|
| 258 | 258 | |
| 259 | 259 | if ( false !== $accommodation ) { |
| 260 | 260 | $searched_items = false; |
@@ -263,7 +263,7 @@ discard block |
||
| 263 | 263 | $keyphrases = $_POST['keyword']; |
| 264 | 264 | }else{ |
| 265 | 265 | $keyphrases = array(0); |
| 266 | - } |
|
| 266 | + } |
|
| 267 | 267 | |
| 268 | 268 | if(!is_array($keyphrases)){ |
| 269 | 269 | $keyphrases = array($keyphrases); |
@@ -304,11 +304,11 @@ discard block |
||
| 304 | 304 | |
| 305 | 305 | if('import' === $post_status){ |
| 306 | 306 | |
| 307 | - if(is_array($this->queued_imports) && in_array($row['post_id'],$this->queued_imports)){ |
|
| 307 | + if(is_array($this->queued_imports) && in_array($row['post_id'],$this->queued_imports)){ |
|
| 308 | 308 | $searched_items[sanitize_title($row['name']).'-'.$row['id']] = $this->format_row($row); |
| 309 | - }else{ |
|
| 310 | - continue; |
|
| 311 | - } |
|
| 309 | + }else{ |
|
| 310 | + continue; |
|
| 311 | + } |
|
| 312 | 312 | |
| 313 | 313 | }else{ |
| 314 | 314 | |
@@ -387,7 +387,7 @@ discard block |
||
| 387 | 387 | * Saves the queue to the option. |
| 388 | 388 | */ |
| 389 | 389 | public function remove_from_queue($id) { |
| 390 | - if (!empty($this->queued_imports)) { |
|
| 390 | + if (!empty($this->queued_imports)) { |
|
| 391 | 391 | |
| 392 | 392 | if(($key = array_search($id, $this->queued_imports)) !== false) { |
| 393 | 393 | unset($this->queued_imports[$key]); |
@@ -395,7 +395,7 @@ discard block |
||
| 395 | 395 | delete_option('wetu_importer_que'); |
| 396 | 396 | update_option('wetu_importer_que',$this->queued_imports); |
| 397 | 397 | } |
| 398 | - } |
|
| 398 | + } |
|
| 399 | 399 | } |
| 400 | 400 | |
| 401 | 401 | /** |
@@ -433,18 +433,18 @@ discard block |
||
| 433 | 433 | $content = false; |
| 434 | 434 | } |
| 435 | 435 | |
| 436 | - $jdata = file_get_contents( $this->url . '/Get?' . $this->url_qs . '&ids=' . $wetu_id ); |
|
| 437 | - if($jdata) |
|
| 438 | - { |
|
| 439 | - $adata=json_decode($jdata,true); |
|
| 440 | - if(!empty($adata)) |
|
| 441 | - { |
|
| 442 | - $return = $this->import_row($adata,$wetu_id,$post_id,$team_members,$content,$safari_brands); |
|
| 443 | - $this->format_completed_row($return); |
|
| 444 | - $this->remove_from_queue($return); |
|
| 436 | + $jdata = file_get_contents( $this->url . '/Get?' . $this->url_qs . '&ids=' . $wetu_id ); |
|
| 437 | + if($jdata) |
|
| 438 | + { |
|
| 439 | + $adata=json_decode($jdata,true); |
|
| 440 | + if(!empty($adata)) |
|
| 441 | + { |
|
| 442 | + $return = $this->import_row($adata,$wetu_id,$post_id,$team_members,$content,$safari_brands); |
|
| 443 | + $this->format_completed_row($return); |
|
| 444 | + $this->remove_from_queue($return); |
|
| 445 | 445 | $this->cleanup_posts(); |
| 446 | - } |
|
| 447 | - } |
|
| 446 | + } |
|
| 447 | + } |
|
| 448 | 448 | } |
| 449 | 449 | } |
| 450 | 450 | |
@@ -454,144 +454,144 @@ discard block |
||
| 454 | 454 | public function import_row($data,$wetu_id,$id=0,$team_members=false,$importable_content=false,$safari_brands=false) { |
| 455 | 455 | |
| 456 | 456 | |
| 457 | - $post_name = $data_post_content = $data_post_excerpt = ''; |
|
| 458 | - $post = array( |
|
| 459 | - 'post_type' => 'accommodation', |
|
| 460 | - ); |
|
| 461 | - |
|
| 462 | - $content_used_general_description = false; |
|
| 463 | - |
|
| 464 | - //Set the post_content |
|
| 465 | - if(false !== $importable_content && in_array('description',$importable_content)){ |
|
| 466 | - if(isset($data[0]['content']['extended_description'])) |
|
| 467 | - { |
|
| 468 | - $data_post_content = $data[0]['content']['extended_description']; |
|
| 469 | - }elseif(isset($data[0]['content']['general_description'])){ |
|
| 470 | - $data_post_content = $data[0]['content']['general_description']; |
|
| 471 | - $content_used_general_description = true; |
|
| 472 | - }elseif(isset($data[0]['content']['teaser_description'])){ |
|
| 473 | - $data_post_content = $data[0]['content']['teaser_description']; |
|
| 474 | - } |
|
| 475 | - $post['post_content'] = wp_strip_all_tags($data_post_content); |
|
| 476 | - } |
|
| 477 | - |
|
| 478 | - //set the post_excerpt |
|
| 479 | - if(false !== $importable_content && in_array('excerpt',$importable_content)){ |
|
| 480 | - if(isset($data[0]['content']['teaser_description'])){ |
|
| 481 | - $data_post_excerpt = $data[0]['content']['teaser_description']; |
|
| 482 | - }elseif(isset($data[0]['content']['general_description']) && false === $content_used_general_description){ |
|
| 483 | - $data_post_excerpt = $data[0]['content']['general_description']; |
|
| 484 | - } |
|
| 485 | - $post['post_excerpt'] = $data_post_excerpt; |
|
| 486 | - } |
|
| 487 | - |
|
| 488 | - if(false !== $id && '0' !== $id){ |
|
| 489 | - $post['ID'] = $id; |
|
| 457 | + $post_name = $data_post_content = $data_post_excerpt = ''; |
|
| 458 | + $post = array( |
|
| 459 | + 'post_type' => 'accommodation', |
|
| 460 | + ); |
|
| 461 | + |
|
| 462 | + $content_used_general_description = false; |
|
| 463 | + |
|
| 464 | + //Set the post_content |
|
| 465 | + if(false !== $importable_content && in_array('description',$importable_content)){ |
|
| 466 | + if(isset($data[0]['content']['extended_description'])) |
|
| 467 | + { |
|
| 468 | + $data_post_content = $data[0]['content']['extended_description']; |
|
| 469 | + }elseif(isset($data[0]['content']['general_description'])){ |
|
| 470 | + $data_post_content = $data[0]['content']['general_description']; |
|
| 471 | + $content_used_general_description = true; |
|
| 472 | + }elseif(isset($data[0]['content']['teaser_description'])){ |
|
| 473 | + $data_post_content = $data[0]['content']['teaser_description']; |
|
| 474 | + } |
|
| 475 | + $post['post_content'] = wp_strip_all_tags($data_post_content); |
|
| 476 | + } |
|
| 477 | + |
|
| 478 | + //set the post_excerpt |
|
| 479 | + if(false !== $importable_content && in_array('excerpt',$importable_content)){ |
|
| 480 | + if(isset($data[0]['content']['teaser_description'])){ |
|
| 481 | + $data_post_excerpt = $data[0]['content']['teaser_description']; |
|
| 482 | + }elseif(isset($data[0]['content']['general_description']) && false === $content_used_general_description){ |
|
| 483 | + $data_post_excerpt = $data[0]['content']['general_description']; |
|
| 484 | + } |
|
| 485 | + $post['post_excerpt'] = $data_post_excerpt; |
|
| 486 | + } |
|
| 487 | + |
|
| 488 | + if(false !== $id && '0' !== $id){ |
|
| 489 | + $post['ID'] = $id; |
|
| 490 | 490 | if(isset($data[0]['name'])){ |
| 491 | 491 | $post['post_title'] = $data[0]['name']; |
| 492 | - $post['post_status'] = 'publish'; |
|
| 492 | + $post['post_status'] = 'publish'; |
|
| 493 | 493 | $post['post_name'] = wp_unique_post_slug(sanitize_title($data[0]['name']),$id, 'draft', 'accommodation', 0); |
| 494 | 494 | } |
| 495 | - $id = wp_update_post($post); |
|
| 496 | - $prev_date = get_post_meta($id,'lsx_wetu_modified_date',true); |
|
| 497 | - update_post_meta($id,'lsx_wetu_modified_date',strtotime($data[0]['last_modified']),$prev_date); |
|
| 498 | - }else{ |
|
| 499 | - |
|
| 500 | - //Set the name |
|
| 501 | - if(isset($data[0]['name'])){ |
|
| 502 | - $post_name = wp_unique_post_slug(sanitize_title($data[0]['name']),$id, 'draft', 'accommodation', 0); |
|
| 503 | - } |
|
| 504 | - $post['post_name'] = $post_name; |
|
| 505 | - $post['post_title'] = $data[0]['name']; |
|
| 506 | - $post['post_status'] = 'publish'; |
|
| 507 | - $id = wp_insert_post($post); |
|
| 508 | - |
|
| 509 | - //Save the WETU ID and the Last date it was modified. |
|
| 510 | - if(false !== $id){ |
|
| 511 | - add_post_meta($id,'lsx_wetu_id',$wetu_id); |
|
| 512 | - add_post_meta($id,'lsx_wetu_modified_date',strtotime($data[0]['last_modified'])); |
|
| 513 | - } |
|
| 514 | - } |
|
| 515 | - //Setup some default for use in the import |
|
| 516 | - if(false !== $importable_content && (in_array('gallery',$importable_content) || in_array('banner_image',$importable_content) || in_array('featured_image',$importable_content))){ |
|
| 495 | + $id = wp_update_post($post); |
|
| 496 | + $prev_date = get_post_meta($id,'lsx_wetu_modified_date',true); |
|
| 497 | + update_post_meta($id,'lsx_wetu_modified_date',strtotime($data[0]['last_modified']),$prev_date); |
|
| 498 | + }else{ |
|
| 499 | + |
|
| 500 | + //Set the name |
|
| 501 | + if(isset($data[0]['name'])){ |
|
| 502 | + $post_name = wp_unique_post_slug(sanitize_title($data[0]['name']),$id, 'draft', 'accommodation', 0); |
|
| 503 | + } |
|
| 504 | + $post['post_name'] = $post_name; |
|
| 505 | + $post['post_title'] = $data[0]['name']; |
|
| 506 | + $post['post_status'] = 'publish'; |
|
| 507 | + $id = wp_insert_post($post); |
|
| 508 | + |
|
| 509 | + //Save the WETU ID and the Last date it was modified. |
|
| 510 | + if(false !== $id){ |
|
| 511 | + add_post_meta($id,'lsx_wetu_id',$wetu_id); |
|
| 512 | + add_post_meta($id,'lsx_wetu_modified_date',strtotime($data[0]['last_modified'])); |
|
| 513 | + } |
|
| 514 | + } |
|
| 515 | + //Setup some default for use in the import |
|
| 516 | + if(false !== $importable_content && (in_array('gallery',$importable_content) || in_array('banner_image',$importable_content) || in_array('featured_image',$importable_content))){ |
|
| 517 | 517 | $this->find_attachments($id); |
| 518 | 518 | } |
| 519 | 519 | |
| 520 | - //Set the team member if it is there |
|
| 521 | - if(post_type_exists('team') && false !== $team_members && '' !== $team_members){ |
|
| 522 | - $this->set_team_member($id,$team_members); |
|
| 523 | - } |
|
| 524 | - |
|
| 525 | - //Set the safari brand |
|
| 526 | - if(false !== $safari_brands && '' !== $safari_brands){ |
|
| 527 | - $this->set_safari_brands($id,$safari_brands); |
|
| 528 | - |
|
| 529 | - } |
|
| 530 | - |
|
| 531 | - if(class_exists('LSX_TO_Maps')){ |
|
| 532 | - $this->set_map_data($data,$id,9); |
|
| 533 | - } |
|
| 534 | - |
|
| 535 | - if(post_type_exists('destination') && false !== $importable_content && in_array('destination',$importable_content)){ |
|
| 536 | - $this->connect_destinations($data,$id); |
|
| 537 | - } |
|
| 538 | - |
|
| 539 | - if(false !== $importable_content && in_array('category',$importable_content)){ |
|
| 540 | - $this->set_taxonomy_style($data,$id); |
|
| 541 | - } |
|
| 542 | - |
|
| 543 | - //Set the Room Data |
|
| 544 | - if(false !== $importable_content && in_array('rooms',$importable_content)){ |
|
| 545 | - $this->set_room_data($data,$id); |
|
| 546 | - } |
|
| 547 | - |
|
| 548 | - //Set the rating |
|
| 549 | - if(false !== $importable_content && in_array('rating',$importable_content)){ |
|
| 550 | - $this->set_rating($data,$id); |
|
| 551 | - } |
|
| 552 | - |
|
| 553 | - //Set the checkin checkout data |
|
| 554 | - if(false !== $importable_content && in_array('checkin',$importable_content)){ |
|
| 555 | - $this->set_checkin_checkout($data,$id); |
|
| 556 | - } |
|
| 557 | - |
|
| 558 | - //Set the Spoken Languages |
|
| 559 | - if(false !== $importable_content && in_array('spoken_languages',$importable_content)){ |
|
| 560 | - $this->set_spoken_languages($data,$id); |
|
| 561 | - } |
|
| 562 | - |
|
| 563 | - //Set the friendly options |
|
| 564 | - if(false !== $importable_content && in_array('friendly',$importable_content)){ |
|
| 565 | - $this->set_friendly($data,$id); |
|
| 566 | - } |
|
| 567 | - |
|
| 568 | - //Set the special_interests |
|
| 569 | - if(false !== $importable_content && in_array('special_interests',$importable_content)){ |
|
| 570 | - $this->set_special_interests($data,$id); |
|
| 571 | - } |
|
| 572 | - |
|
| 573 | - //Import the videos |
|
| 574 | - if(false !== $importable_content && in_array('videos',$importable_content)){ |
|
| 575 | - $this->set_video_data($data,$id); |
|
| 576 | - } |
|
| 577 | - |
|
| 578 | - //Import the facilities |
|
| 579 | - if(false !== $importable_content && in_array('facilities',$importable_content)){ |
|
| 580 | - $this->set_facilities($data,$id); |
|
| 581 | - } |
|
| 582 | - |
|
| 583 | - //Set the featured image |
|
| 584 | - if(false !== $importable_content && in_array('featured_image',$importable_content)){ |
|
| 585 | - $this->set_featured_image($data,$id); |
|
| 586 | - } |
|
| 587 | - if(false !== $importable_content && in_array('banner_image',$importable_content)){ |
|
| 588 | - $this->set_banner_image($data,$id); |
|
| 589 | - } |
|
| 590 | - //Import the main gallery |
|
| 591 | - if(false !== $importable_content && in_array('gallery',$importable_content)){ |
|
| 592 | - $this->create_main_gallery($data,$id); |
|
| 593 | - } |
|
| 594 | - return $id; |
|
| 520 | + //Set the team member if it is there |
|
| 521 | + if(post_type_exists('team') && false !== $team_members && '' !== $team_members){ |
|
| 522 | + $this->set_team_member($id,$team_members); |
|
| 523 | + } |
|
| 524 | + |
|
| 525 | + //Set the safari brand |
|
| 526 | + if(false !== $safari_brands && '' !== $safari_brands){ |
|
| 527 | + $this->set_safari_brands($id,$safari_brands); |
|
| 528 | + |
|
| 529 | + } |
|
| 530 | + |
|
| 531 | + if(class_exists('LSX_TO_Maps')){ |
|
| 532 | + $this->set_map_data($data,$id,9); |
|
| 533 | + } |
|
| 534 | + |
|
| 535 | + if(post_type_exists('destination') && false !== $importable_content && in_array('destination',$importable_content)){ |
|
| 536 | + $this->connect_destinations($data,$id); |
|
| 537 | + } |
|
| 538 | + |
|
| 539 | + if(false !== $importable_content && in_array('category',$importable_content)){ |
|
| 540 | + $this->set_taxonomy_style($data,$id); |
|
| 541 | + } |
|
| 542 | + |
|
| 543 | + //Set the Room Data |
|
| 544 | + if(false !== $importable_content && in_array('rooms',$importable_content)){ |
|
| 545 | + $this->set_room_data($data,$id); |
|
| 546 | + } |
|
| 547 | + |
|
| 548 | + //Set the rating |
|
| 549 | + if(false !== $importable_content && in_array('rating',$importable_content)){ |
|
| 550 | + $this->set_rating($data,$id); |
|
| 551 | + } |
|
| 552 | + |
|
| 553 | + //Set the checkin checkout data |
|
| 554 | + if(false !== $importable_content && in_array('checkin',$importable_content)){ |
|
| 555 | + $this->set_checkin_checkout($data,$id); |
|
| 556 | + } |
|
| 557 | + |
|
| 558 | + //Set the Spoken Languages |
|
| 559 | + if(false !== $importable_content && in_array('spoken_languages',$importable_content)){ |
|
| 560 | + $this->set_spoken_languages($data,$id); |
|
| 561 | + } |
|
| 562 | + |
|
| 563 | + //Set the friendly options |
|
| 564 | + if(false !== $importable_content && in_array('friendly',$importable_content)){ |
|
| 565 | + $this->set_friendly($data,$id); |
|
| 566 | + } |
|
| 567 | + |
|
| 568 | + //Set the special_interests |
|
| 569 | + if(false !== $importable_content && in_array('special_interests',$importable_content)){ |
|
| 570 | + $this->set_special_interests($data,$id); |
|
| 571 | + } |
|
| 572 | + |
|
| 573 | + //Import the videos |
|
| 574 | + if(false !== $importable_content && in_array('videos',$importable_content)){ |
|
| 575 | + $this->set_video_data($data,$id); |
|
| 576 | + } |
|
| 577 | + |
|
| 578 | + //Import the facilities |
|
| 579 | + if(false !== $importable_content && in_array('facilities',$importable_content)){ |
|
| 580 | + $this->set_facilities($data,$id); |
|
| 581 | + } |
|
| 582 | + |
|
| 583 | + //Set the featured image |
|
| 584 | + if(false !== $importable_content && in_array('featured_image',$importable_content)){ |
|
| 585 | + $this->set_featured_image($data,$id); |
|
| 586 | + } |
|
| 587 | + if(false !== $importable_content && in_array('banner_image',$importable_content)){ |
|
| 588 | + $this->set_banner_image($data,$id); |
|
| 589 | + } |
|
| 590 | + //Import the main gallery |
|
| 591 | + if(false !== $importable_content && in_array('gallery',$importable_content)){ |
|
| 592 | + $this->create_main_gallery($data,$id); |
|
| 593 | + } |
|
| 594 | + return $id; |
|
| 595 | 595 | } |
| 596 | 596 | |
| 597 | 597 | /** |
@@ -601,7 +601,7 @@ discard block |
||
| 601 | 601 | |
| 602 | 602 | delete_post_meta($id, 'team_to_'.$this->tab_slug); |
| 603 | 603 | foreach($team_members as $team){ |
| 604 | - add_post_meta($id,'team_to_'.$this->tab_slug,$team); |
|
| 604 | + add_post_meta($id,'team_to_'.$this->tab_slug,$team); |
|
| 605 | 605 | } |
| 606 | 606 | } |
| 607 | 607 | |
@@ -610,7 +610,7 @@ discard block |
||
| 610 | 610 | */ |
| 611 | 611 | public function set_safari_brands($id,$safari_brands) { |
| 612 | 612 | foreach($safari_brands as $safari_brand){ |
| 613 | - wp_set_object_terms( $id, intval($safari_brand), 'accommodation-brand',true); |
|
| 613 | + wp_set_object_terms( $id, intval($safari_brand), 'accommodation-brand',true); |
|
| 614 | 614 | } |
| 615 | 615 | } |
| 616 | 616 | |
@@ -619,32 +619,32 @@ discard block |
||
| 619 | 619 | */ |
| 620 | 620 | public function connect_destinations($data,$id) { |
| 621 | 621 | if(isset($data[0]['position'])){ |
| 622 | - $destinations = false; |
|
| 623 | - if(isset($data[0]['position']['country'])){ |
|
| 624 | - $destinations['country'] = $data[0]['position']['country']; |
|
| 625 | - } |
|
| 626 | - if(isset($data[0]['position']['destination'])){ |
|
| 627 | - $destinations['destination'] = $data[0]['position']['destination']; |
|
| 628 | - } |
|
| 622 | + $destinations = false; |
|
| 623 | + if(isset($data[0]['position']['country'])){ |
|
| 624 | + $destinations['country'] = $data[0]['position']['country']; |
|
| 625 | + } |
|
| 626 | + if(isset($data[0]['position']['destination'])){ |
|
| 627 | + $destinations['destination'] = $data[0]['position']['destination']; |
|
| 628 | + } |
|
| 629 | 629 | |
| 630 | - if(false !== $destinations){ |
|
| 631 | - $prev_values = get_post_meta($id,'destination_to_accommodation',false); |
|
| 632 | - if(false === $prev_values || !is_array($prev_values)){ |
|
| 633 | - $prev_values = array(); |
|
| 634 | - } |
|
| 635 | - //print_r($destinations); |
|
| 630 | + if(false !== $destinations){ |
|
| 631 | + $prev_values = get_post_meta($id,'destination_to_accommodation',false); |
|
| 632 | + if(false === $prev_values || !is_array($prev_values)){ |
|
| 633 | + $prev_values = array(); |
|
| 634 | + } |
|
| 635 | + //print_r($destinations); |
|
| 636 | 636 | $destinations = array_unique($destinations); |
| 637 | 637 | //print_r($destinations); |
| 638 | - foreach($destinations as $key => $value){ |
|
| 639 | - $destination = get_page_by_title(ltrim(rtrim($value)), 'OBJECT', 'destination'); |
|
| 640 | - if (null !== $destination) { |
|
| 641 | - if(!in_array($destination->ID,$prev_values)){ |
|
| 642 | - add_post_meta($id,'destination_to_accommodation',$destination->ID,false); |
|
| 643 | - add_post_meta($destination->ID,'accommodation_to_destination',$id,false); |
|
| 638 | + foreach($destinations as $key => $value){ |
|
| 639 | + $destination = get_page_by_title(ltrim(rtrim($value)), 'OBJECT', 'destination'); |
|
| 640 | + if (null !== $destination) { |
|
| 641 | + if(!in_array($destination->ID,$prev_values)){ |
|
| 642 | + add_post_meta($id,'destination_to_accommodation',$destination->ID,false); |
|
| 643 | + add_post_meta($destination->ID,'accommodation_to_destination',$id,false); |
|
| 644 | 644 | $this->cleanup_posts[$destination->ID] = 'accommodation_to_destination'; |
| 645 | - } |
|
| 646 | - } |
|
| 647 | - } |
|
| 645 | + } |
|
| 646 | + } |
|
| 647 | + } |
|
| 648 | 648 | } |
| 649 | 649 | } |
| 650 | 650 | } |
@@ -656,15 +656,15 @@ discard block |
||
| 656 | 656 | $terms = false; |
| 657 | 657 | if(isset($data[0]['category'])){ |
| 658 | 658 | if(!$term = term_exists(trim($data[0]['category']), 'accommodation-type')) |
| 659 | - { |
|
| 660 | - $term = wp_insert_term(trim($data[0]['category']), 'accommodation-type'); |
|
| 661 | - if ( is_wp_error($term) ){echo $term->get_error_message();} |
|
| 662 | - else { wp_set_object_terms( $id, intval($term['term_id']), 'accommodation-type',true); } |
|
| 663 | - } |
|
| 664 | - else |
|
| 665 | - { |
|
| 666 | - wp_set_object_terms( $id, intval($term['term_id']), 'accommodation-type',true); |
|
| 667 | - } |
|
| 659 | + { |
|
| 660 | + $term = wp_insert_term(trim($data[0]['category']), 'accommodation-type'); |
|
| 661 | + if ( is_wp_error($term) ){echo $term->get_error_message();} |
|
| 662 | + else { wp_set_object_terms( $id, intval($term['term_id']), 'accommodation-type',true); } |
|
| 663 | + } |
|
| 664 | + else |
|
| 665 | + { |
|
| 666 | + wp_set_object_terms( $id, intval($term['term_id']), 'accommodation-type',true); |
|
| 667 | + } |
|
| 668 | 668 | } |
| 669 | 669 | } |
| 670 | 670 | |
@@ -688,25 +688,25 @@ discard block |
||
| 688 | 688 | $temp_room['type'] = 'room'; |
| 689 | 689 | |
| 690 | 690 | if(!empty($room['images']) && is_array($room['images'])){ |
| 691 | - $attachments_args = array( |
|
| 692 | - 'post_parent' => $id, |
|
| 693 | - 'post_status' => 'inherit', |
|
| 694 | - 'post_type' => 'attachment', |
|
| 695 | - 'order' => 'ASC', |
|
| 696 | - ); |
|
| 697 | - $attachments = new WP_Query($attachments_args); |
|
| 698 | - $found_attachments = array(); |
|
| 699 | - |
|
| 700 | - if($attachments->have_posts()){ |
|
| 701 | - foreach($attachments->posts as $attachment){ |
|
| 702 | - $found_attachments[] = str_replace(array('.jpg','.png','.jpeg'),'',$attachment->post_title); |
|
| 703 | - } |
|
| 704 | - } |
|
| 691 | + $attachments_args = array( |
|
| 692 | + 'post_parent' => $id, |
|
| 693 | + 'post_status' => 'inherit', |
|
| 694 | + 'post_type' => 'attachment', |
|
| 695 | + 'order' => 'ASC', |
|
| 696 | + ); |
|
| 697 | + $attachments = new WP_Query($attachments_args); |
|
| 698 | + $found_attachments = array(); |
|
| 699 | + |
|
| 700 | + if($attachments->have_posts()){ |
|
| 701 | + foreach($attachments->posts as $attachment){ |
|
| 702 | + $found_attachments[] = str_replace(array('.jpg','.png','.jpeg'),'',$attachment->post_title); |
|
| 703 | + } |
|
| 704 | + } |
|
| 705 | 705 | |
| 706 | 706 | $temp_room['gallery'] = array(); |
| 707 | 707 | foreach($room['images'] as $image_data){ |
| 708 | - $temp_room['gallery'][] = $this->attach_image($image_data,$id,$found_attachments); |
|
| 709 | - } |
|
| 708 | + $temp_room['gallery'][] = $this->attach_image($image_data,$id,$found_attachments); |
|
| 709 | + } |
|
| 710 | 710 | } |
| 711 | 711 | $rooms[] = $temp_room; |
| 712 | 712 | } |
@@ -715,7 +715,7 @@ discard block |
||
| 715 | 715 | delete_post_meta($id, 'units'); |
| 716 | 716 | } |
| 717 | 717 | foreach($rooms as $room){ |
| 718 | - add_post_meta($id,'units',$room,false); |
|
| 718 | + add_post_meta($id,'units',$room,false); |
|
| 719 | 719 | } |
| 720 | 720 | |
| 721 | 721 | if(isset($data[0]['features']) && isset($data[0]['features']['rooms'])){ |
@@ -725,11 +725,11 @@ discard block |
||
| 725 | 725 | } |
| 726 | 726 | |
| 727 | 727 | if(false !== $id && '0' !== $id){ |
| 728 | - $prev_rooms = get_post_meta($id,'number_of_rooms',true); |
|
| 729 | - update_post_meta($id,'number_of_rooms',$room_count,$prev_rooms); |
|
| 730 | - }else{ |
|
| 731 | - add_post_meta($id,'number_of_rooms',$room_count,true); |
|
| 732 | - } |
|
| 728 | + $prev_rooms = get_post_meta($id,'number_of_rooms',true); |
|
| 729 | + update_post_meta($id,'number_of_rooms',$room_count,$prev_rooms); |
|
| 730 | + }else{ |
|
| 731 | + add_post_meta($id,'number_of_rooms',$room_count,true); |
|
| 732 | + } |
|
| 733 | 733 | } |
| 734 | 734 | } |
| 735 | 735 | |