PluginProbe
MLSImport: IDX Plugin & MLS Plugin for Real Estate Listings / 7.1.2
MLSImport: IDX Plugin & MLS Plugin for Real Estate Listings v7.1.2
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-status-normalize.php

mlsimport-status-normalize.php in MLSImport: IDX Plugin & MLS Plugin for Real Estate Listings 7.1.2, at includes/mlsimport-status-normalize.php

33 lines 1.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Pure normalizer for MLS status enum values.
4 *
5 * Trestle's PrettyEnums=true returns spaced enum labels ("Active Under
6 * Contract") while the plugin's status config and older imports store the raw
7 * RESO enum ("ActiveUnderContract"). Both forms must compare equal, so every
8 * status comparison funnels its operands through this normalizer: lowercase
9 * and strip spaces, yielding a single stable key ("activeundercontract").
10 *
11 * No WordPress calls — safe to unit-test in isolation.
12 */
13
14 if ( ! defined( 'ABSPATH' ) ) {
15 exit;
16 }
17
18 /**
19 * Reduce a status enum value to its comparison key.
20 *
21 * @param mixed $value Raw or PrettyEnums status value (anything non-string yields '').
22 * @return string Lowercased, space-free comparison key.
23 */
24 function mlsimport_normalize_status_enum( $value ) {
25 // Non-string input has no comparable status; normalize to empty.
26 if ( ! is_string( $value ) ) {
27 return '';
28 }
29
30 // Trim, lowercase, then drop spaces so "Active Under Contract" == "ActiveUnderContract".
31 return str_replace( ' ', '', strtolower( trim( $value ) ) );
32 }
33