Plugin Directory

Changeset 3389696


Ignore:
Timestamp:
11/04/2025 01:22:27 PM (5 months ago)
Author:
PropertyHive
Message:

Update to version 2.5.34

Location:
houzez-property-feed/trunk
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • houzez-property-feed/trunk/README.txt

    r3389596 r3389696  
    44Requires at least: 3.8
    55Tested up to: 6.8
    6 Stable tag: 2.5.33
    7 Version: 2.5.33
     6Stable tag: 2.5.34
     7Version: 2.5.34
    88Homepage: https://houzezpropertyfeed.com
    99License: GPLv3
     
    144144== Changelog ==
    145145
     146= 2.5.34 - 2025-11-04 =
     147* Started to roll out new 'Test Details' feature to some formats. This allows the user to test the details are valid when entering them before continuing any further.
     148
    146149= 2.5.33 - 2025-11-04 =
    147150* Updated license functionality to also consider upcoming annual pricing model
  • houzez-property-feed/trunk/assets/js/admin-import.js

    r3325700 r3389696  
    222222    });
    223223    //
     224
     225    jQuery('a.test-import-details').click(function(e)
     226    {
     227        e.preventDefault();
     228
     229        var test_button = jQuery(this);
     230
     231        test_button.parent().find('.test-results-success').hide();
     232        test_button.parent().find('.test-results-error').hide();
     233
     234        jQuery(this).html('Testing...');
     235        jQuery(this).attr('disabled', 'disabled');
     236
     237        var format = jQuery(this).data('format');
     238
     239        var parentTd = jQuery('#import_settings_' + format);
     240
     241        var data = {
     242            'action': 'houzez_property_feed_test_property_import_details',
     243            'format': format
     244        };
     245
     246        // Find all input fields within that 'td'
     247        var inputs = parentTd.find('input, select');
     248
     249        parentTd.find('input, select').each(function()
     250        {
     251            var element = jQuery(this);
     252            var element_name = element.attr('name').replace(format + "_", "");
     253
     254            // Handle checkboxes
     255            if (element.attr('type') === 'checkbox') {
     256                data[element_name] = element.is(':checked') ? element.val() : 'no';
     257            // Handle select fields
     258            } else if (element.is('select')) {
     259                // Handle multi-select
     260                if (element.prop('multiple')) {
     261                    data[element_name] = element.val() || [];
     262                } else {
     263                    // Handle single select
     264                    data[element_name] = element.val();
     265                }
     266            // Handle other input fields (e.g., text, number, etc.)
     267            } else {
     268                data[element_name] = element.val();
     269            }
     270        });
     271
     272        jQuery.post( ajaxurl, data, function(response)
     273        {
     274            if ( response.success == true )
     275            {
     276                test_button.parent().find('.test-results-success').html('<p>Details appear valid. ' + response.properties + ' properties found for importing.</p>');
     277                test_button.parent().find('.test-results-success').show();
     278            }
     279            else
     280            {
     281                test_button.parent().find('.test-results-error').html('<p>' + response.error + '</p>');
     282                test_button.parent().find('.test-results-error').show();
     283            }
     284
     285            test_button.html('Test Details');
     286            test_button.attr('disabled', false);
     287        });
     288    });
    224289
    225290    if ( jQuery('.automatic-imports-table').length > 0 )
  • houzez-property-feed/trunk/houzez-property-feed.php

    r3389596 r3389696  
    44 * Plugin Uri: https://houzezpropertyfeed.com
    55 * Description: Automatically import properties to Houzez from estate agency CRMs and export to portals
    6  * Version: 2.5.33
     6 * Version: 2.5.34
    77 * Author: PropertyHive
    88 * Author URI: https://wp-property-hive.com
     
    2020     * @var string
    2121     */
    22     public $version = '2.5.33';
     22    public $version = '2.5.34';
    2323
    2424    /**
  • houzez-property-feed/trunk/includes/class-houzez-property-feed-ajax.php

    r3323531 r3389696  
    2424
    2525        add_action( "wp_ajax_houzez_property_feed_import_import", array( $this, "import_import" ) );
     26
     27        add_action( 'wp_ajax_houzez_property_feed_test_property_import_details', array( $this, 'test_property_import_details' ) );
    2628    }
    2729
     
    725727        wp_send_json_success(array('url' => admin_url('admin.php?page=houzez-property-feed-import&hpfsuccessmessage=' . base64_encode('Import completed successfully.'))));
    726728    }
     729
     730    public function test_property_import_details()
     731    {
     732        header( 'Content-Type: application/json; charset=utf-8' );
     733
     734        $format = isset($_POST['format']) ? sanitize_text_field(wp_unslash($_POST['format'])) : '';
     735
     736        if ( empty($format) )
     737        {
     738            $return = array(
     739                'success' => false,
     740                'error' => __( 'No format passed', 'houzezpropertyfeed' )
     741            );
     742            echo json_encode($return);
     743            die();
     744        }
     745
     746        $import_object = hpf_get_import_object_from_format( $format, '', '' );
     747
     748        if ( $import_object === false || empty($import_object) )
     749        {
     750            $return = array(
     751                'success' => false,
     752                'error' => __( 'Couldn\'t create import object', 'houzezpropertyfeed' )
     753            );
     754            echo json_encode($return);
     755            die();
     756        }
     757
     758        $parsed = $import_object->parse(true);
     759
     760        if ( !$parsed )
     761        {
     762            $errors = ( isset($import_object->errors) ? $import_object->errors : array() );
     763            $error = 'Please check they are correct.';
     764            if ( !empty($errors) )
     765            {
     766                $error = $errors[array_key_last($errors)];
     767                $explode_error = explode(" - ", $error, 2);
     768                if ( count($explode_error) == 2 )
     769                {
     770                    $error = $explode_error[1];
     771                }
     772            }
     773
     774            $return = array(
     775                'success' => false,
     776                'error' => 'An error occurred whilst obtaining the properties using the details provided:<br><br>' . nl2br(esc_html($error))
     777            );
     778            echo json_encode($return);
     779            die();
     780        }
     781        else
     782        {
     783            $return = array(
     784                'success' => true,
     785                'properties' => count($import_object->properties)
     786            );
     787            echo json_encode($return);
     788            die();
     789        }
     790
     791        wp_die();
     792    }
    727793}
    728794
  • houzez-property-feed/trunk/includes/class-houzez-property-feed-license.php

    r3389596 r3389696  
    141141        $instance_id = get_option( 'houzez_property_feed_instance_id', '' );
    142142
    143         $product_ids_to_try = array(17, 3943);
     143        $product_ids_to_try = array(17, 3944, 3945);
    144144        $last_error_message = '';
    145145        $last_body_dump     = '';
     
    238238        }
    239239
    240         $product_ids_to_try = array(17, 3943);
     240        $product_ids_to_try = array(17, 3944, 3945);
    241241        $last_error = '';
    242242
     
    278278                    die();
    279279                } else {
     280                   
    280281                    $last_error = __( 'Error when activating license key', 'houzezpropertyfeed' ) . ': ' . $body['error'];
    281282                    continue;
     
    288289
    289290        // If we reach here, all attempts failed
    290         wp_redirect( admin_url( 'admin.php?page=' . ( isset($_GET['page']) ? sanitize_text_field($_GET['page']) : 'houzez-property-feed-import' ) . '&tab=license&hpferrormessage=' . base64_encode( $last_error ) ) );
     291        wp_redirect( admin_url( 'admin.php?page=' . ( isset($_GET['page']) ? sanitize_text_field($_GET['page']) : 'houzez-property-feed-import' ) . '&tab=license&hpferrormessage=' . base64_encode( urlencode($last_error) ) ) );
    291292        die();
    292293    }
     
    299300        $instance_id = get_option( 'houzez_property_feed_instance_id', '' );
    300301
    301         $product_ids_to_try = array(17, 3943);
     302        $product_ids_to_try = array(17, 3944, 3945);
    302303        $last_error = '';
    303304
     
    349350
    350351        // If we reach here, all attempts failed
    351         wp_redirect( admin_url( 'admin.php?page=' . ( isset($_GET['page']) ? sanitize_text_field($_GET['page']) : 'houzez-property-feed-import' ) . '&tab=license&hpferrormessage=' . base64_encode( $last_error ) ) );
     352        wp_redirect( admin_url( 'admin.php?page=' . ( isset($_GET['page']) ? sanitize_text_field($_GET['page']) : 'houzez-property-feed-import' ) . '&tab=license&hpferrormessage=' . base64_encode( urlencode($last_error) ) ) );
    352353        die();
    353354    }
  • houzez-property-feed/trunk/includes/class-houzez-property-feed-process.php

    r3358551 r3389696  
    3939     */
    4040    public $background_mode = false;
     41
     42    /**
     43     * @var array
     44     * Used in testing
     45     */
     46    public $errors = array();
    4147
    4248    public function __construct()
     
    392398            if ( $this->is_import ) { $this->ping(); }
    393399        }
     400
     401        $this->errors[] = $message;
    394402    }
    395403
  • houzez-property-feed/trunk/includes/format-functions.php

    r3389138 r3389696  
    105105            'help_url' => 'https://houzezpropertyfeed.com/documentation/managing-imports/formats/10ninety/',
    106106            'warnings' => array_filter( array( $simplexml_warning ) ),
     107            'test_button' => true,
    107108            'background_mode' => true,
    108109        ),
     
    149150            'help_url' => 'https://houzezpropertyfeed.com/documentation/managing-imports/formats/acquaint/',
    150151            'warnings' => array_filter( array( $simplexml_warning ) ),
     152            'test_button' => true,
    151153            'background_mode' => true,
    152154        ),
     
    267269            ),
    268270            'help_url' => 'https://houzezpropertyfeed.com/documentation/managing-imports/formats/agestanet/',
     271            'test_button' => true,
    269272            'warnings' => array_filter( array( $simplexml_warning ) ),
    270273        ),
  • houzez-property-feed/trunk/includes/import-formats/class-houzez-property-feed-format-10ninety.php

    r3389596 r3389696  
    2424    }
    2525
    26     public function parse()
     26    public function parse( $test = false )
    2727    {
    28         $this->properties = array(); // Reset properties in the event we're importing multiple files
     28        $this->properties = array();
     29
     30        if ( $test === false || $troubleshooting === true )
     31        {
     32            $import_settings = houzez_property_feed_get_import_settings_from_id( $this->import_id );
     33            $test = true;
     34        }
     35        else
     36        {
     37            $import_settings = map_deep( wp_unslash($_POST), 'sanitize_text_field' );
     38            if ( isset( $_POST['xml_url'] ) )
     39            {
     40                $import_settings['xml_url'] = sanitize_url( wp_unslash( $_POST['xml_url'] ) );
     41            }
     42        }
    2943
    3044        $this->log("Parsing properties", '', 0, '', false);
    31 
    32         $import_settings = houzez_property_feed_get_import_settings_from_id( $this->import_id );
    3345
    3446        $pro_active = apply_filters( 'houzez_property_feed_pro_active', false );
     
    8799            foreach ($xml->property as $property)
    88100            {
    89                 if ( $limit !== FALSE && count($this->properties) >= $limit )
     101                if ( $test === false && $limit !== FALSE && count($this->properties) >= $limit )
    90102                {
    91103                    return true;
     
    94106                $this->properties[] = $property;
    95107
    96                 if ( $background_mode === true )
     108                if ( $test === false && $background_mode === true )
    97109                {
    98110                    $this->write_to_queue( (string)$property->AGENT_REF, $property );
     
    108120        }
    109121
    110         if ( empty($this->properties) )
     122        if ( $test === false && empty($this->properties) )
    111123        {
    112124            $this->log_error( 'No properties found. We\'re not going to continue as this could likely be wrong and all properties will get removed if we continue.' );
  • houzez-property-feed/trunk/includes/import-formats/class-houzez-property-feed-format-acquaint.php

    r3389596 r3389696  
    2222    }
    2323
    24     public function parse()
     24    public function parse( $test = false )
    2525    {
    26         $this->properties = array(); // Reset properties in the event we're importing multiple files
     26        $this->properties = array();
     27
     28        if ( $test === false || $troubleshooting === true )
     29        {
     30            $import_settings = houzez_property_feed_get_import_settings_from_id( $this->import_id );
     31            $test = true;
     32        }
     33        else
     34        {
     35            $import_settings = map_deep( wp_unslash($_POST), 'sanitize_text_field' );
     36            if ( isset( $_POST['xml_url'] ) )
     37            {
     38                $import_settings['xml_url'] = sanitize_url( wp_unslash( $_POST['xml_url'] ) );
     39            }
     40        }
    2741
    2842        $this->log("Parsing properties", '', 0, '', false);
    29 
    30         $import_settings = houzez_property_feed_get_import_settings_from_id( $this->import_id );
    3143
    3244        $pro_active = apply_filters( 'houzez_property_feed_pro_active', false );
     
    8597            foreach ( $xml->properties->property as $property )
    8698            {
    87                 if ( $limit !== FALSE && count($this->properties) >= $limit )
     99                if ( $test === false && $limit !== FALSE && count($this->properties) >= $limit )
    88100                {
    89101                    return true;
     
    92104                $this->properties[] = $property;
    93105
    94                 if ( $background_mode === true )
     106                if ( $test === false && $background_mode === true )
    95107                {
    96108                    $this->write_to_queue( (string)$property->id, $property );
     
    106118        }
    107119
    108         if ( empty($this->properties) )
     120        if ( $test === false && empty($this->properties) )
    109121        {
    110122            $this->log_error( 'No properties found. We\'re not going to continue as this could likely be wrong and all properties will get removed if we continue.' );
  • houzez-property-feed/trunk/includes/import-formats/class-houzez-property-feed-format-agestanet.php

    r3389596 r3389696  
    2727    }
    2828
    29     public function parse()
     29    public function parse( $test = false )
    3030    {
    31         $this->properties = array(); // Reset properties in the event we're importing multiple files
    32 
    33         $this->log("Parsing properties", '', 0, '', false);
    34 
    35         $import_settings = houzez_property_feed_get_import_settings_from_id( $this->import_id );
    36 
    37         $contents = '';
    38 
    39         $response = wp_remote_get( $import_settings['xml_url'], array( 'timeout' => 360, 'sslverify' => false ) );
    40         if ( !is_wp_error($response) && is_array( $response ) )
     31        $this->properties = array();
     32
     33        if ( $test === false || $troubleshooting === true )
    4134        {
    42             $contents = $response['body'];
     35            $import_settings = houzez_property_feed_get_import_settings_from_id( $this->import_id );
     36            $test = true;
    4337        }
    4438        else
    4539        {
    46             $this->log_error( "Failed to obtain XML. Dump of response as follows: " . print_r($response, TRUE) );
    47 
    48             return false;
     40            $import_settings = map_deep( wp_unslash($_POST), 'sanitize_text_field' );
     41            if ( isset( $_POST['xml_url'] ) )
     42            {
     43                $import_settings['xml_url'] = sanitize_url( wp_unslash( $_POST['xml_url'] ) );
     44            }
    4945        }
     46
     47        $this->log("Parsing properties", '', 0, '', false);
     48
     49        $limit = apply_filters( "houzez_property_feed_property_limit", 25 );
     50        if ( $limit !== false )
     51        {
     52       
     53        }
     54        else
     55        {
     56            // using pro, but check for limit setting
     57            if (
     58                $pro_active === true &&
     59                isset($import_settings['limit']) &&
     60                !empty((int)$import_settings['limit']) &&
     61                is_numeric($import_settings['limit'])
     62            )
     63            {
     64                $limit = (int)$import_settings['limit'];
     65            }
     66        }
     67
     68        $contents = '';
     69
     70        $response = wp_remote_get( $import_settings['xml_url'], array( 'timeout' => 360, 'sslverify' => false ) );
     71
     72        if ( is_wp_error( $response ) )
     73        {
     74            $this->log_error( 'Response: ' . $response->get_error_message() );
     75
     76            return false;
     77        }
     78
     79        if ( wp_remote_retrieve_response_code($response) !== 200 )
     80        {
     81            $this->log_error( wp_remote_retrieve_response_code($response) . ' response received when requesting properties. Error message: ' . wp_remote_retrieve_response_message($response) );
     82            return false;
     83        }
     84
     85        $contents = $response['body'];
    5086
    5187        $xml = simplexml_load_string($contents);
     
    5591            foreach ( $xml->immobili->immobile as $property )
    5692            {
     93                if ( $test === false && $limit !== FALSE && count($this->properties) >= $limit )
     94                {
     95                    return true;
     96                }
     97
    5798                $this->properties[] = $property;
    5899            }
     
    66107        }
    67108
    68         if ( empty($this->properties) )
     109        if ( $test === false && empty($this->properties) )
    69110        {
    70111            $this->log_error( 'No properties found. We\'re not going to continue as this could likely be wrong and all properties will get removed if we continue.' );
  • houzez-property-feed/trunk/includes/views/admin-settings-import-settings-format.php

    r3255514 r3389696  
    239239        <?php
    240240            }
     241            if ( isset($format['test_button']) && $format['test_button'] === true )
     242            {
     243                echo '<tr>
     244                    <th>&nbsp;</th>
     245                    <td>
     246                        <a href="" data-format="' . $key . '" class="test-import-details button">Test Details</a>
     247                        <div class="test-results-success notice notice-success inline" style="display:none; margin-top:20px"></div>
     248                        <div class="test-results-error notice notice-error inline" style="display:none; margin-top:20px"></div>
     249                    </td>
     250                </tr>';
     251            }
    241252        ?>
    242253    </tbody>
Note: See TracChangeset for help on using the changeset viewer.