Plugin Directory

Changeset 3416398


Ignore:
Timestamp:
12/10/2025 12:33:56 PM (2 months ago)
Author:
apimofficiel
Message:

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

  • Version 2.6.4
  • Updated: Fix security bug
Location:
apimo/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • apimo/trunk/apimo.php

    r3235381 r3416398  
    77 * Description: Manage Real Estat Bussiness
    88
    9  * Version: 2.6.3.1
     9 * Version: 2.6.4
    1010
    1111 * Author: ApiWork
  • apimo/trunk/readme.txt

    r3274825 r3416398  
    33Tags: real estate, property management, listings, clients, leads, showings, open houses, reports
    44Tested up to: 6.7.1
    5 Stable tag: 2.6.3.1
     5Stable tag: 2.6.4
    66License: GPLv2
    77License URI: https://www.gnu.org/licenses/gpl-2.0.html
    88
    9 == Description ==
    10 Are you a real estate agent or broker looking to streamline your daily operations?
    11 
    12 Discover Apimo connector — a powerful, user-friendly WordPress plugin designed to help you:
    13 – Effortlessly list and manage properties for sale or rent
    14 – Organize and track showings and open houses with ease
    15 
    16 This plugin integrates smoothly with your existing WordPress site and is built with simplicity and efficiency in mind.
    17 
    18 Please note: Apimo Connector is not an official Apimo plugin and is not developed by Apimo.
    19 
    20 Start simplifying your real estate workflow today with Manage Real Estate Business!
     9Are you a real estate agent or broker looking for a way to streamline your business operations? Look no further! Our plugin is here to help.
     10
     11With Manage Real Estate Business, you can easily:
     12
     13- List and manage properties for sale or rent
     14- Schedule and manage showings and open houses
     15
     16Our plugin integrates seamlessly with your WordPress website and is user-friendly and intuitive. Start streamlining your real estate business today with Manage Real Estate Business!
    2117
    2218== Installation ==
     
    149145The plugin is specifically designed to work with the Apimo API. Importing properties from a different platform would require custom development to integrate the other platform's API with the plugin.
    150146
     147= How can I contact support if I have issues with the plugin? =
     148
     149For support with the plugin, you can contact the Apimo support team through their official website or email. Ensure you have your token and provider ID ready for quicker assistance.
     150
    151151= How do I update the plugin to the latest version? =
    152152
     
    174174
    175175== Changelog ==
     176
     177= 2.6.4 =
     178*fix: dynamically send leads to correct Apimo agency
     179*Previous implementation always sent leads to a hardcoded agency.
     180*Now detects the agency based on property reference (if available).
     181*Falls back to the first saved agency if no property reference is present.
     182*Ensures leads from product pages go to the correct agency in Apimo.
     183*Improves API integration and prevents misrouted leads.
    176184
    177185= 2.6.3 =
  • apimo/trunk/templates/single_property_style_2.php

    r3235354 r3416398  
    18281828
    18291829            $apimo_api_keys = get_option('apimo_key_data');
    1830 
     1830           
    18311831            $company_id = trim($apimo_api_keys[0]['company_id']);
    18321832            $key = trim($apimo_api_keys[0]['key']);
    1833             $credentials = base64_encode($company_id . ':' . $key); // Add the colon separator here
     1833            $credentials = base64_encode($company_id . ':' . $key); // Add the colon separator
    18341834           
    1835 
    18361835            if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    1837                 // Configuration Apimo
     1836
     1837                /**
     1838                 * ------------------------------------
     1839                 *  HOTFIX: Detect the correct agency
     1840                 * ------------------------------------
     1841                 */
     1842                $dynamic_agency_id = null;
     1843
     1844                // CASE 1: Lead sent from a property page (contains property reference)
     1845                if (!empty($_POST['reference'])) {
     1846
     1847                    $property_ref = sanitize_text_field($_POST['reference']);
     1848
     1849                    // Fetch the property to get its agency ID
     1850                    $ch_property = curl_init("https://api.apimo.pro/properties/{$property_ref}");
     1851                    curl_setopt_array($ch_property, [
     1852                        CURLOPT_RETURNTRANSFER => true,
     1853                        CURLOPT_HTTPHEADER => [
     1854                            'Authorization: Basic ' . $credentials,
     1855                            'Content-Type: application/json'
     1856                        ]
     1857                    ]);
     1858
     1859                    $property_response = curl_exec($ch_property);
     1860                    curl_close($ch_property);
     1861
     1862                    $property_json = json_decode($property_response, true);
     1863
     1864                    // If the property has an agency → use it
     1865                    if (!empty($property_json['agency']['id'])) {
     1866                        $dynamic_agency_id = $property_json['agency']['id'];
     1867                    }
     1868                }
     1869
     1870                // CASE 2: No property reference → use first agency saved
     1871                if (!$dynamic_agency_id) {
     1872                    $dynamic_agency_id = $apimo_api_keys[0]['agency_id'];
     1873                }
     1874
     1875                // Build correct API config
    18381876                $apimoConfig = [
    18391877                    'apiUrl' => 'https://api.apimo.pro/agencies',
    1840                     'agencyId' => '23531        ',
     1878                    'agencyId' => $dynamic_agency_id,
    18411879                    'credentials' => $credentials
    18421880                ];
    18431881
    1844                 // Validate form
     1882                /**
     1883                 * ------------------------------------
     1884                 *  Validate form
     1885                 * ------------------------------------
     1886                 */
    18451887                $errors = [];
    1846                
     1888
    18471889                if (empty($_POST['lastName'])) {
    18481890                    $errors[] = 'Le nom est requis';
    18491891                }
    1850                
     1892
    18511893                if (empty($_POST['email']) && empty($_POST['phone'])) {
    18521894                    $errors[] = 'Email ou téléphone est requis';
     
    18611903                }
    18621904
    1863                 // If no errors, process form
     1905                /**
     1906                 * ------------------------------------
     1907                 *  Submit to Apimo API
     1908                 * ------------------------------------
     1909                 */
    18641910                if (empty($errors)) {
    1865                     // Prepare data for API
     1911
     1912                    // Prepare data
    18661913                    $leadData = [
    18671914                        'reference' => uniqid('WP-'),
     
    18731920                        'currency' => 'EUR',
    18741921                        'referral' => '1',
    1875                        
    1876                         // Form data
     1922
     1923                        // Form fields
    18771924                        'lastname' => strip_tags($_POST['lastName']),
    18781925                        'firstname' => strip_tags($_POST['firstName'] ?? ''),
     
    18831930                    ];
    18841931
    1885                     // Initialize cURL
     1932                    // Send lead
    18861933                    $ch = curl_init(rtrim($apimoConfig['apiUrl'], '/') . '/' . trim($apimoConfig['agencyId']) . '/leads');
    1887                    
     1934
    18881935                    curl_setopt_array($ch, [
    18891936                        CURLOPT_POST => true,
     
    18951942                        CURLOPT_POSTFIELDS => json_encode($leadData)
    18961943                    ]);
    1897                    
     1944
    18981945                    $response = curl_exec($ch);
    18991946                    $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    1900                    
     1947
    19011948                    if (curl_errno($ch)) {
    1902                         echo '<div class="apimo_error">Erreur de connexion à l\'API: ' . curl_error($ch) . '</div>';
     1949                        echo '<div class="apimo_error">API connection error: ' . curl_error($ch) . '</div>';
    19031950                    } elseif ($httpCode !== 200) {
    1904                         echo '<div class="apimo_error">Erreur API Apimo: ' . $response . '</div>';
     1951                        echo '<div class="apimo_error">Apimo API error: ' . $response . '</div>';
    19051952                    }
    1906                    
     1953
    19071954                    curl_close($ch);
     1955
    19081956                } else {
    1909                     // Display errors
     1957
    19101958                    echo '<div class="apimo_error">';
    19111959                    foreach ($errors as $error) {
     
    19131961                    }
    19141962                    echo '</div>';
     1963
    19151964                }
    19161965            }
     1966
    19171967        ?>
    19181968
Note: See TracChangeset for help on using the changeset viewer.