Plugin Directory

Changeset 3091018


Ignore:
Timestamp:
05/22/2024 03:50:47 PM (21 months ago)
Author:
apimofficiel
Message:

Commit Message:
===============

  • Version 2.5.7
  • Added: Support for optional Sector ID in API integration.
  • Updated: Settings interface to include Sector ID field.
  • Enhanced: Validation process to handle the presence or absence of Sector ID.
Location:
apimo/trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • apimo/trunk/admin/add_property.php

    r3036187 r3091018  
    9292
    9393
    94     $apimo_api_keys =  get_option('apimo_key_data');
    95 
     94
     95    $apimo_api_keys = get_option('apimo_key_data');
    9696    $api_property_array = array();
    9797
    9898    if (!empty($apimo_api_keys)) :
    99 
    10099        foreach ($apimo_api_keys as $data_keys) {
    101 
    102 
    103 
    104100            if (!$data_keys['is_valid']) {
    105 
    106101                continue;
    107102            }
    108103
    109 
    110 
    111104            $company_id = $data_keys['company_id'];
    112 
    113105            $api_key = $data_keys['key'];
    114 
    115106            $agencies_id = $data_keys['agency_id'];
    116 
     107            $sector_id = !empty($data_keys['sector_id']) ? '-' . $data_keys['sector_id'] : '';
    117108            $auth = base64_encode($company_id . ':' . $api_key);
    118109
    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(
    121111                'headers' => array(
    122 
    123112                    'Content-Type' => 'application/json',
    124 
    125113                    'Authorization' => 'Basic ' . $auth
    126 
    127114                ),
    128 
    129115            ));
    130116
    131 
    132 
    133117            if (is_wp_error($result)) {
    134 
    135118                return;
    136119            }
    137120
    138 
    139 
    140121            $data = json_decode($result['body']);
    141 
    142122            $i = 1;
    143123
    144 
    145 
    146 
    147 
    148124            foreach ($data->properties as $property) {
    149 
    150 
    151 
    152125                $i++;
    153 
    154126                $api_property_array[] = $property->id;
    155 
    156 
    157 
    158127                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 
    173128                as_schedule_single_action(strtotime('+' . $i . ' second'), 'apimo_import_single_property', array($property->id));
    174 
    175129                update_option("apimo_add_property_by_api", $api_property_array);
    176130            }
    177131        }
    178 
    179132    endif;
     133
    180134}
    181135
  • apimo/trunk/admin/settings.php

    r3069734 r3091018  
    163163
    164164
     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
    165192$apimo_api_keys = get_option('apimo_key_data');
    166 
    167193$uniqueProviderIDs = [];
    168194$uniqueAgencyIDs = [];
     
    178204    }
    179205
    180    
    181206    $uniqueProviderIDs = array_unique($uniqueProviderIDs);
    182207    $uniqueAgencyIDs = array_unique($uniqueAgencyIDs);
     
    498523                    </div>
    499524                </div>
    500             </div>         
     525            </div>   
     526
    501527            <div class="apimo-block apimo_setting_section general-setting">
    502 
    503528                <div class="apimo-block-header">
    504 
    505529                    <h3><?php _e('General settings', 'apimo'); ?></h3>
    506 
    507530                </div>
    508 
    509531                <div class="apimo-block-body apimo-section-description">
    510 
    511532                    <div class="apimo-api-key-information">
    512 
    513533                        <div class="apimo-api-key-information-row-wrap">
    514534                            <?php
    515535                            if (!empty($apimo_api_keys)):
    516                            
    517536                                foreach ($apimo_api_keys as $data):
    518537                                    if ($data['key'] == '' && $data['company_id'] == '') {
    519 
    520538                                        continue;
    521 
    522                                     }
     539                                    }
    523540                                    $provider_id = $data['company_id'];
    524541                                    if (!isset($providers[$provider_id])) {
     
    528545                                endforeach; 
    529546                                $i = 0;
    530                                 foreach ($providers as $provider_id => $agencies){
    531                                    
     547                                foreach ($providers as $provider_id => $agencies):
    532548                                    ?>
    533549                                    <div class="apimo-api-key-information-row">
    534 
    535550                                        <div class="apimo-row apimo-row-v-center">
    536 
    537551                                            <div class="apimo-col-3 col-btn">
    538552                                                <button type="button" class="apimo-remove-data">
    539553                                                    <svg id="Modalità_Isolamento" data-name="Modalità Isolamento" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 408.61 408.8">
    540 
    541554                                                        <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 
    543555                                                    </svg>
    544556                                                </button>
    545557                                            </div>
    546 
    547 
    548 
    549558                                            <div class="apimo-col-3">
    550559                                                <label class="apimo-compnay-id-box">
     
    552561                                                        <?php _e('Provider ID', 'apimo'); ?>
    553562                                                    </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 ); ?>" />
    555564                                                </label>
    556565                                            </div>
    557 
    558566                                            <div class="apimo-col-3">
    559567                                                <label class="apimo-api-key-box">
     
    561569                                                    <input type="text" name="inserisci_api_key[]" class="apimo-input_text" value="<?php echo esc_html($agencies[$i]['key']); ?>" />
    562570                                                </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>
    563577                                            </div>
    564 
    565 
    566                                             <div class="apimo-col-3">
    567 
     578                                            <div class="apimo-col-2">
    568579                                                <div class="apimo-valid-invalid">
    569 
    570580                                                    <div class="apimo-valid apimo-api_key_validation" <?php if ($data['is_valid']) {echo 'style="display:flex"';} ?>>
    571 
    572581                                                        <div class="apimo-circle_green"></div>
    573 
    574582                                                        <div class="apimo-validation_text"><?php _e('Your keys are valid'); ?></div>
    575 
    576                                                     </div>
    577 
     583                                                    </div>
    578584                                                    <div class="apimo-invalid apimo-api_key_validation" <?php if (!$data['is_valid']) {echo 'style="display:flex"';} ?>>
    579 
    580585                                                        <div class="apimo-circle_red"></div>
    581 
    582586                                                        <div class="apimo-validation_text"><?php _e('Your keys are not valid'); ?></div>
    583 
    584                                                     </div>
    585 
     587                                                    </div>
    586588                                                </div>
    587 
    588589                                            </div>
    589                                             <div class="apimo-col-3">
     590                                            <div class="apimo-col-4">
    590591                                                <?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']); ?>
    597597                                                        </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;
    600604                                                ?>
    601605                                            </div>
    602 
    603606                                        </div>
    604 
    605607                                    </div>
    606608                                    <?php
    607 
    608                                    
    609                                 }
    610                                
    611 
     609                                endforeach;
    612610                            endif;
    613611                            ?>
    614 
    615612                        </div>
    616 
    617613                    </div>
    618 
    619614                </div>
    620 
    621615                <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>
    625620                </div>
    626 
    627621                <div class="apimo-api-key-information-row" id="apimo-api-key-information-row-clone" style="display:none">
    628 
    629622                    <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">
    633626                                    <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>
    642648                        <div class="apimo-col-3">
    643 
    644649                            <div class="apimo-valid-invalid">
    645 
    646650                                <div class="apimo-valid apimo-api_key_validation">
    647 
    648651                                    <div class="apimo-circle_green"></div>
    649 
    650652                                    <div class="apimo-validation_text"><?php _e('Your keys are valid'); ?></div>
    651 
    652653                                </div>
    653 
    654654                                <div class="apimo-invalid apimo-api_key_validation">
    655 
    656655                                    <div class="apimo-circle_red"></div>
    657 
    658656                                    <div class="apimo-validation_text"><?php _e('Your keys are not valid'); ?></div>
    659 
    660657                                </div>
    661 
    662                             </div>
    663 
     658                            </div>
    664659                        </div>
    665 
    666660                    </div>
    667 
    668661                </div>
    669 
    670             </div>
     662            </div>
     663
     664
     665
    671666            <!--Scheduled -->
    672667            <div style="padding: 30px;" class="apimo-block">
  • apimo/trunk/apimo.php

    r3069734 r3091018  
    77* Description: Manage Real Estat Bussiness
    88
    9 * Version: 2.5.6
     9* Version: 2.5.7
    1010
    1111* Author: ApiWork
  • apimo/trunk/assets/css/admin.css

    r3069734 r3091018  
    416416}
    417417
     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}
    418452
    419453
  • apimo/trunk/assets/js/admin.js

    r3069734 r3091018  
    270270
    271271
     272
    272273jQuery(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 = [];
    277277
    278278    jQuery('.apimo-input_text[name="inserisci_api_key[]"]').each(function () {
    279 
    280279        api_key.push(jQuery(this).val())
    281 
    282280    })
    283281
    284282    jQuery('.apimo-input_text[name="apimo_company_id[]"]').each(function () {
    285 
    286283        company_id.push(jQuery(this).val())
    287 
    288284    })
    289285
     286    jQuery('.apimo-input_text[name="sector_id[]"]').each(function () {
     287        sector_id.push(jQuery(this).val())
     288    })
     289
    290290    var data = {
    291 
    292291        'action': 'apimo_check_api_key',
    293 
    294292        'api_key': api_key,
    295 
    296293        'company_id': company_id,
    297 
    298     }
    299 
    300 
     294        'sector_id': sector_id
     295    }
    301296
    302297    jQuery.post(admin_urls.ajax, data, function (response) {
    303 
    304 
    305 
    306298        jQuery('.apimo-api-key-information-row-wrap .apimo-api-key-information-row').each(function (index) {
    307 
    308 
    309 
    310299            var is_valid = response[index].is_valid;
    311 
    312300            if (is_valid) {
    313 
    314301                jQuery(this).find('.apimo-valid').show();
    315                
    316 
    317302                jQuery(this).find('.apimo-invalid').hide();
    318 
    319303            } else {
    320 
    321304                jQuery(this).find('.apimo-valid').hide();
    322 
    323305                jQuery(this).find('.apimo-invalid').show();
    324306                jQuery(this).find('.apimo-invalid').html(response[index].message);
    325 
    326307            }
    327 
    328308        })
    329 
    330 
    331 
    332309        jQuery('.apimo_api_responce').html(response);
    333310        window.location.reload();
    334 
    335311    });
    336 
    337 });
    338 
     312});
    339313
    340314
  • apimo/trunk/includes/apimo_ajax.php

    r3069734 r3091018  
    44
    55add_action("wp_ajax_nopriv_apimo_check_api_key", 'apimo_check_api_key');
    6 
    7 
    86
    97
     
    1917            }
    2018
    21 
    22 
    2319            $company_id = filter_var($_POST['company_id'][$key], FILTER_SANITIZE_NUMBER_INT);
    24 
    2520            $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) : '';
    2822
    2923            if ($company_id === false) {
     
    3428                exit("api key is not valid");
    3529            }
    36 
    37 
    3830
    3931            $auth = base64_encode($company_id . ':' . $api_key);
     
    4941                )
    5042            );
     43
    5144            if (!is_wp_error($result)) {
    5245                $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                }
    6756            } else {
    68                 $is_valid = false;
    6957                $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                );
    7066            }
    7167        }
     
    7470    wp_send_json($key_data);
    7571}
    76 
    7772
    7873
  • apimo/trunk/readme.txt

    r3069734 r3091018  
    33Tags: real estate, property management, listings, clients, leads, showings, open houses, reports
    44Tested up to: 6.4.2
    5 Stable tag: 2.5.6
     5Stable tag: 2.5.7
    66License: GPLv2
    77License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    9494== Changelog ==
    9595
    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
    104101
    105102
Note: See TracChangeset for help on using the changeset viewer.