PluginProbe
MLSImport: IDX Plugin & MLS Plugin for Real Estate Listings / 7.1.1
MLSImport: IDX Plugin & MLS Plugin for Real Estate Listings v7.1.1
7.2.1 7.2 7.1.2 7.1.1 7.1 7.0.4 7.0.6 7.0.7 6.3.8 6.3.7 6.3.6 6.3.5 6.3.4 6.3.3 6.3.1 trunk 5.7.3 5.7.5 5.8.1 5.8.2 5.8.3 5.8.4 5.8.6 6.0.4 6.0.5 All 36 releases
mlsimport / includes / mlsimport-country.php

mlsimport-country.php in MLSImport: IDX Plugin & MLS Plugin for Real Estate Listings 7.1.1, at includes/mlsimport-country.php

42 lines 1.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Country resolution for newly created listings.
4 *
5 * The parsed listing arrives from the SaaS with the feed's own country under
6 * meta.property_country: the Lambda maps the RESO `Country` field into that
7 * key and translates ISO codes to full names (Centris's "CA" → "Canada").
8 * The WpResidence projection historically hardcoded "United States" over it
9 * for every new listing, which mislabelled Canadian imports.
10 *
11 * Step by step:
12 * 1. Read meta.property_country from the parsed property.
13 * 2. If the feed sent a non-empty country, keep it.
14 * 3. Otherwise return the historical default, "United States", so US feeds
15 * that omit the field behave exactly as before.
16 *
17 * Kept WordPress-free so the rule is unit-testable
18 * (tests/PropertyCountryTest.php) without loading the theme adapters.
19 *
20 * @package Mlsimport
21 * @subpackage Mlsimport/includes
22 */
23
24 if ( ! defined( 'ABSPATH' ) ) {
25 exit;
26 }
27
28 /**
29 * Resolve the country name to store for a listing.
30 *
31 * @param array $property Parsed incoming property (SaaS structure).
32 * @return string Full country name for the theme's property_country meta.
33 */
34 function mlsimport_property_country( $property ) {
35 $country = $property['meta']['property_country'] ?? '';
36 if ( is_string( $country ) && '' !== $country ) {
37 return $country;
38 }
39
40 return 'United States';
41 }
42