Changeset 3091018
- Timestamp:
- 05/22/2024 03:50:47 PM (21 months ago)
- Location:
- apimo/trunk
- Files:
-
- 7 edited
-
admin/add_property.php (modified) (1 diff)
-
admin/settings.php (modified) (6 diffs)
-
apimo.php (modified) (1 diff)
-
assets/css/admin.css (modified) (1 diff)
-
assets/js/admin.js (modified) (1 diff)
-
includes/apimo_ajax.php (modified) (5 diffs)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
apimo/trunk/admin/add_property.php
r3036187 r3091018 92 92 93 93 94 $apimo_api_keys = get_option('apimo_key_data'); 95 94 95 $apimo_api_keys = get_option('apimo_key_data'); 96 96 $api_property_array = array(); 97 97 98 98 if (!empty($apimo_api_keys)) : 99 100 99 foreach ($apimo_api_keys as $data_keys) { 101 102 103 104 100 if (!$data_keys['is_valid']) { 105 106 101 continue; 107 102 } 108 103 109 110 111 104 $company_id = $data_keys['company_id']; 112 113 105 $api_key = $data_keys['key']; 114 115 106 $agencies_id = $data_keys['agency_id']; 116 107 $sector_id = !empty($data_keys['sector_id']) ? '-' . $data_keys['sector_id'] : ''; 117 108 $auth = base64_encode($company_id . ':' . $api_key); 118 109 119 $result = wp_remote_get('https://api.apimo.pro/agencies/' . $agencies_id . '/properties', array( 120 110 $result = wp_remote_get('https://api.apimo.pro/agencies/' . $agencies_id . $sector_id . '/properties', array( 121 111 'headers' => array( 122 123 112 'Content-Type' => 'application/json', 124 125 113 'Authorization' => 'Basic ' . $auth 126 127 114 ), 128 129 115 )); 130 116 131 132 133 117 if (is_wp_error($result)) { 134 135 118 return; 136 119 } 137 120 138 139 140 121 $data = json_decode($result['body']); 141 142 122 $i = 1; 143 123 144 145 146 147 148 124 foreach ($data->properties as $property) { 149 150 151 152 125 $i++; 153 154 126 $api_property_array[] = $property->id; 155 156 157 158 127 update_option('apimo_property_data_' . $property->id, $property); 159 // apimo_add_new_property($property->id);160 // if ($property->id == '7294963') {161 162 // print_r($property);163 // apimo_add_new_property($property->id);164 165 166 167 // exit;168 // } else {169 // continue;170 // }171 172 173 128 as_schedule_single_action(strtotime('+' . $i . ' second'), 'apimo_import_single_property', array($property->id)); 174 175 129 update_option("apimo_add_property_by_api", $api_property_array); 176 130 } 177 131 } 178 179 132 endif; 133 180 134 } 181 135 -
apimo/trunk/admin/settings.php
r3069734 r3091018 163 163 164 164 165 // $apimo_api_keys = get_option('apimo_key_data'); 166 167 // $uniqueProviderIDs = []; 168 // $uniqueAgencyIDs = []; 169 170 // if (is_array($apimo_api_keys)) { 171 // foreach ($apimo_api_keys as $keyData) { 172 // if (isset($keyData['company_id'])) { 173 // $uniqueProviderIDs[] = $keyData['company_id']; 174 // } 175 // if (isset($keyData['agency_id'])) { 176 // $uniqueAgencyIDs[] = $keyData['agency_id']; 177 // } 178 // } 179 180 181 // $uniqueProviderIDs = array_unique($uniqueProviderIDs); 182 // $uniqueAgencyIDs = array_unique($uniqueAgencyIDs); 183 184 // // Count the unique IDs 185 // $providerIDCount = count($uniqueProviderIDs); 186 // $agencyIDCount = count($uniqueAgencyIDs); 187 188 // update_option('providerIDCounts', $providerIDCount); 189 // update_option('agencyIDCounts', $agencyIDCount); 190 // } 191 165 192 $apimo_api_keys = get_option('apimo_key_data'); 166 167 193 $uniqueProviderIDs = []; 168 194 $uniqueAgencyIDs = []; … … 178 204 } 179 205 180 181 206 $uniqueProviderIDs = array_unique($uniqueProviderIDs); 182 207 $uniqueAgencyIDs = array_unique($uniqueAgencyIDs); … … 498 523 </div> 499 524 </div> 500 </div> 525 </div> 526 501 527 <div class="apimo-block apimo_setting_section general-setting"> 502 503 528 <div class="apimo-block-header"> 504 505 529 <h3><?php _e('General settings', 'apimo'); ?></h3> 506 507 530 </div> 508 509 531 <div class="apimo-block-body apimo-section-description"> 510 511 532 <div class="apimo-api-key-information"> 512 513 533 <div class="apimo-api-key-information-row-wrap"> 514 534 <?php 515 535 if (!empty($apimo_api_keys)): 516 517 536 foreach ($apimo_api_keys as $data): 518 537 if ($data['key'] == '' && $data['company_id'] == '') { 519 520 538 continue; 521 522 } 539 } 523 540 $provider_id = $data['company_id']; 524 541 if (!isset($providers[$provider_id])) { … … 528 545 endforeach; 529 546 $i = 0; 530 foreach ($providers as $provider_id => $agencies){ 531 547 foreach ($providers as $provider_id => $agencies): 532 548 ?> 533 549 <div class="apimo-api-key-information-row"> 534 535 550 <div class="apimo-row apimo-row-v-center"> 536 537 551 <div class="apimo-col-3 col-btn"> 538 552 <button type="button" class="apimo-remove-data"> 539 553 <svg id="Modalità_Isolamento" data-name="Modalità Isolamento" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 408.61 408.8"> 540 541 554 <path d="M294.54,239A204.44,204.44,0,0,0,5.46,239c-79.68,79.7-79.68,209.37,0,289.07a204.41,204.41,0,0,0,289.07,0c79.68-79.7,79.68-209.38,0-289.07ZM253,403.1H47.06V363.9H253Z" transform="translate(54.3 -179.1)" /> 542 543 555 </svg> 544 556 </button> 545 557 </div> 546 547 548 549 558 <div class="apimo-col-3"> 550 559 <label class="apimo-compnay-id-box"> … … 552 561 <?php _e('Provider ID', 'apimo'); ?> 553 562 </span> 554 <input type="text" name="apimo_company_id[]" class="apimo-input_text" value="<?php echo esc_html($provider_id ); ?>" />563 <input type="text" name="apimo_company_id[]" class="apimo-input_text" value="<?php echo esc_html($provider_id ); ?>" /> 555 564 </label> 556 565 </div> 557 558 566 <div class="apimo-col-3"> 559 567 <label class="apimo-api-key-box"> … … 561 569 <input type="text" name="inserisci_api_key[]" class="apimo-input_text" value="<?php echo esc_html($agencies[$i]['key']); ?>" /> 562 570 </label> 571 </div> 572 <div class="apimo-col-3"> 573 <label class="apimo-sector-id-box"> 574 <span><?php _e('Sector ID (optional)', 'apimo'); ?></span> 575 <input type="text" name="sector_id[]" class="apimo-input_text" value="<?php echo esc_html($agencies[$i]['sector_id']); ?>" /> 576 </label> 563 577 </div> 564 565 566 <div class="apimo-col-3"> 567 578 <div class="apimo-col-2"> 568 579 <div class="apimo-valid-invalid"> 569 570 580 <div class="apimo-valid apimo-api_key_validation" <?php if ($data['is_valid']) {echo 'style="display:flex"';} ?>> 571 572 581 <div class="apimo-circle_green"></div> 573 574 582 <div class="apimo-validation_text"><?php _e('Your keys are valid'); ?></div> 575 576 </div> 577 583 </div> 578 584 <div class="apimo-invalid apimo-api_key_validation" <?php if (!$data['is_valid']) {echo 'style="display:flex"';} ?>> 579 580 585 <div class="apimo-circle_red"></div> 581 582 586 <div class="apimo-validation_text"><?php _e('Your keys are not valid'); ?></div> 583 584 </div> 585 587 </div> 586 588 </div> 587 588 589 </div> 589 <div class="apimo-col- 3">590 <div class="apimo-col-4"> 590 591 <?php 591 foreach ($agencies as $agency): 592 ?> 593 <div class="apimo-agency"> 594 <div class="apimo-agency-info"> 595 <strong><?php _e('Agence ID', 'apimo'); ?>:</strong> <?php echo esc_html($agency['agency_id']); ?> 596 </div> 592 foreach ($agencies as $agency): 593 ?> 594 <div class="apimo-agency"> 595 <div class="apimo-agency-info"> 596 <strong><?php _e('Agence ID', 'apimo'); ?>:</strong> <?php echo esc_html($agency['agency_id']); ?> 597 597 </div> 598 <?php 599 endforeach; 598 <div class="apimo-agency-info"> 599 <strong><?php _e('Sector ID', 'apimo'); ?>:</strong> <?php echo esc_html($agency['sector_id']); ?> 600 </div> 601 </div> 602 <?php 603 endforeach; 600 604 ?> 601 605 </div> 602 603 606 </div> 604 605 607 </div> 606 608 <?php 607 608 609 } 610 611 609 endforeach; 612 610 endif; 613 611 ?> 614 615 612 </div> 616 617 613 </div> 618 619 614 </div> 620 621 615 <div class="apimo-footer align-right apimo-api-information-save"> 622 623 <div class=""> <button type="button" class="button button-outline apimo-input_button " id="add_new_agency"><?php _e("Add new agency", 'apimo'); ?></button> <input type="button" name="check_api_key" value="<?php _e('Validate Key/Save', 'apimo'); ?>" class="button button-primary wt_iew_export_action_btn apimo-input_button" /> </div> 624 616 <div class=""> 617 <button type="button" class="button button-outline apimo-input_button" id="add_new_agency"><?php _e("Add new agency", 'apimo'); ?></button> 618 <input type="button" name="check_api_key" value="<?php _e('Validate Key/Save', 'apimo'); ?>" class="button button-primary wt_iew_export_action_btn apimo-input_button" /> 619 </div> 625 620 </div> 626 627 621 <div class="apimo-api-key-information-row" id="apimo-api-key-information-row-clone" style="display:none"> 628 629 622 <div class="apimo-row apimo-row-v-center"> 630 631 <div class="apimo-col-3 col-btn"> <button type="button" class="apimo-remove-data"> <svg id="Modalità_Isolamento" data-name="Modalità Isolamento" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 408.61 408.8">632 623 <div class="apimo-col-3 col-btn"> 624 <button type="button" class="apimo-remove-data"> 625 <svg id="Modalità_Isolamento" data-name="Modalità Isolamento" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 408.61 408.8"> 633 626 <path d="M294.54,239A204.44,204.44,0,0,0,5.46,239c-79.68,79.7-79.68,209.37,0,289.07a204.41,204.41,0,0,0,289.07,0c79.68-79.7,79.68-209.38,0-289.07ZM253,403.1H47.06V363.9H253Z" transform="translate(54.3 -179.1)" /> 634 635 </svg> </button> </div> 636 637 <div class="apimo-col-3"> <label class="apimo-compnay-id-box"> <span class="apimo-general-setting-label"><?php _e('Provider ID', 'apimo'); ?></span> <input type="text" name="apimo_company_id[]" class="apimo-input_text" value="" /> </label> </div> 638 639 640 <div class="apimo-col-3"> <label class="apimo-api-key-box"> <span><?php _e('Add your API key', 'apimo'); ?></span> <input type="text" name="inserisci_api_key[]" class="apimo-input_text" value="" /> </label> </div> 641 627 </svg> 628 </button> 629 </div> 630 <div class="apimo-col-3"> 631 <label class="apimo-compnay-id-box"> 632 <span class="apimo-general-setting-label"><?php _e('Provider ID', 'apimo'); ?></span> 633 <input type="text" name="apimo_company_id[]" class="apimo-input_text" value="" /> 634 </label> 635 </div> 636 <div class="apimo-col-3"> 637 <label class="apimo-api-key-box"> 638 <span><?php _e('Add your API key', 'apimo'); ?></span> 639 <input type="text" name="inserisci_api_key[]" class="apimo-input_text" value="" /> 640 </label> 641 </div> 642 <div class="apimo-col-3"> 643 <label class="apimo-sector-id-box"> 644 <span><?php _e('Sector ID (optional)', 'apimo'); ?></span> 645 <input type="text" name="sector_id[]" class="apimo-input_text" value="" /> 646 </label> 647 </div> 642 648 <div class="apimo-col-3"> 643 644 649 <div class="apimo-valid-invalid"> 645 646 650 <div class="apimo-valid apimo-api_key_validation"> 647 648 651 <div class="apimo-circle_green"></div> 649 650 652 <div class="apimo-validation_text"><?php _e('Your keys are valid'); ?></div> 651 652 653 </div> 653 654 654 <div class="apimo-invalid apimo-api_key_validation"> 655 656 655 <div class="apimo-circle_red"></div> 657 658 656 <div class="apimo-validation_text"><?php _e('Your keys are not valid'); ?></div> 659 660 657 </div> 661 662 </div> 663 658 </div> 664 659 </div> 665 666 660 </div> 667 668 661 </div> 669 670 </div> 662 </div> 663 664 665 671 666 <!--Scheduled --> 672 667 <div style="padding: 30px;" class="apimo-block"> -
apimo/trunk/apimo.php
r3069734 r3091018 7 7 * Description: Manage Real Estat Bussiness 8 8 9 * Version: 2.5. 69 * Version: 2.5.7 10 10 11 11 * Author: ApiWork -
apimo/trunk/assets/css/admin.css
r3069734 r3091018 416 416 } 417 417 418 419 .apimo-sector-id-box, 420 421 .apimo-compnay-id-box { 422 423 display: flex; 424 425 flex-direction: column; 426 427 } 428 429 .apimo-sector-id-box span, 430 431 .apimo-compnay-id-box span { 432 433 display: block; 434 435 min-width: 150px; 436 437 } 438 439 .apimo-sector-id-box .apimo-input_text, 440 441 .apimo-compnay-id-box .apimo-input_text { 442 443 width: 100%; 444 445 } 446 447 .apimo-sector-id-box .apimo-input_button { 448 449 margin-left: 10px; 450 451 } 418 452 419 453 -
apimo/trunk/assets/js/admin.js
r3069734 r3091018 270 270 271 271 272 272 273 jQuery(document).on('click', '.apimo-input_button[name="check_api_key"]', function () { 273 274 var api_key = []; //jQuery('.apimo-input_text[name="inserisci_api_key[]"]').val(); 275 276 var company_id = [];//jQuery('.apimo-input_text[name="apimo_company_id"]').val(); 274 var api_key = []; 275 var company_id = []; 276 var sector_id = []; 277 277 278 278 jQuery('.apimo-input_text[name="inserisci_api_key[]"]').each(function () { 279 280 279 api_key.push(jQuery(this).val()) 281 282 280 }) 283 281 284 282 jQuery('.apimo-input_text[name="apimo_company_id[]"]').each(function () { 285 286 283 company_id.push(jQuery(this).val()) 287 288 284 }) 289 285 286 jQuery('.apimo-input_text[name="sector_id[]"]').each(function () { 287 sector_id.push(jQuery(this).val()) 288 }) 289 290 290 var data = { 291 292 291 'action': 'apimo_check_api_key', 293 294 292 'api_key': api_key, 295 296 293 'company_id': company_id, 297 298 } 299 300 294 'sector_id': sector_id 295 } 301 296 302 297 jQuery.post(admin_urls.ajax, data, function (response) { 303 304 305 306 298 jQuery('.apimo-api-key-information-row-wrap .apimo-api-key-information-row').each(function (index) { 307 308 309 310 299 var is_valid = response[index].is_valid; 311 312 300 if (is_valid) { 313 314 301 jQuery(this).find('.apimo-valid').show(); 315 316 317 302 jQuery(this).find('.apimo-invalid').hide(); 318 319 303 } else { 320 321 304 jQuery(this).find('.apimo-valid').hide(); 322 323 305 jQuery(this).find('.apimo-invalid').show(); 324 306 jQuery(this).find('.apimo-invalid').html(response[index].message); 325 326 307 } 327 328 308 }) 329 330 331 332 309 jQuery('.apimo_api_responce').html(response); 333 310 window.location.reload(); 334 335 311 }); 336 337 }); 338 312 }); 339 313 340 314 -
apimo/trunk/includes/apimo_ajax.php
r3069734 r3091018 4 4 5 5 add_action("wp_ajax_nopriv_apimo_check_api_key", 'apimo_check_api_key'); 6 7 8 6 9 7 … … 19 17 } 20 18 21 22 23 19 $company_id = filter_var($_POST['company_id'][$key], FILTER_SANITIZE_NUMBER_INT); 24 25 20 $api_key = sanitize_text_field($_POST['api_key'][$key]); 26 27 21 $sector_id = !empty($_POST['sector_id'][$key]) ? filter_var($_POST['sector_id'][$key], FILTER_SANITIZE_NUMBER_INT) : ''; 28 22 29 23 if ($company_id === false) { … … 34 28 exit("api key is not valid"); 35 29 } 36 37 38 30 39 31 $auth = base64_encode($company_id . ':' . $api_key); … … 49 41 ) 50 42 ); 43 51 44 if (!is_wp_error($result)) { 52 45 $data = json_decode($result['body']); 53 $agency_id = ''; 54 $is_valid = false; 55 $message = ''; 56 foreach ($data->agencies as $_agency) { 57 $key_data[] = array( 58 'key' => $api_key, 59 'company_id' => $company_id, 60 'agency_id' => $_agency->id, 61 'is_valid' => true, 62 'message' => $message 63 ); 64 } 65 66 46 foreach ($data->agencies as $_agency) { 47 $key_data[] = array( 48 'key' => $api_key, 49 'company_id' => $company_id, 50 'agency_id' => $_agency->id, 51 'sector_id' => $sector_id, 52 'is_valid' => true, 53 'message' => '' 54 ); 55 } 67 56 } else { 68 $is_valid = false;69 57 $message = $result->get_error_message(); 58 $key_data[] = array( 59 'key' => $api_key, 60 'company_id' => $company_id, 61 'agency_id' => '', 62 'sector_id' => $sector_id, 63 'is_valid' => false, 64 'message' => $message 65 ); 70 66 } 71 67 } … … 74 70 wp_send_json($key_data); 75 71 } 76 77 72 78 73 -
apimo/trunk/readme.txt
r3069734 r3091018 3 3 Tags: real estate, property management, listings, clients, leads, showings, open houses, reports 4 4 Tested up to: 6.4.2 5 Stable tag: 2.5. 65 Stable tag: 2.5.7 6 6 License: GPLv2 7 7 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 94 94 == Changelog == 95 95 96 = 2.5.6 = 97 * Added: Information icon to shortcode configurator for enhanced guidance. 98 * Added: Clickable photo overlays in photo galleries. 99 * Added: Individual search bar shortcode for listings to improve search functionality. 100 * Fixed: Filter issue on form submissions to ensure reliability. 101 * Improved: General code cleanup for better performance and maintainability. 102 * Refined: Filtering logic to provide more accurate results. 103 * Implemented: Media uninstallation functionality to efficiently manage site resources. 96 = 2.5.7 = 97 * Added support for optional Sector ID in API integration. 98 * Updated settings interface to include Sector ID field. 99 * Enhanced validation process to handle the presence or absence of Sector ID. 100 104 101 105 102
Note: See TracChangeset
for help on using the changeset viewer.