| 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 |
|