| 1 |
<?php |
| 2 |
/** |
| 3 |
* Live MLS passthrough mode — bootstrap. |
| 4 |
* |
| 5 |
* The only live-mode file required from mlsimport.php (seam #1). Loads the |
| 6 |
* module and registers its hooks; every callback self-guards on |
| 7 |
* mlsimport_live_mode_active(), so with the flag off nothing changes. |
| 8 |
* |
| 9 |
* @package Mlsimport |
| 10 |
*/ |
| 11 |
|
| 12 |
if ( ! defined( 'ABSPATH' ) ) { |
| 13 |
exit; |
| 14 |
} |
| 15 |
|
| 16 |
// Pull in every live-mode file in dependency order. Each only defines |
| 17 |
// functions and registers self-guarding hooks; nothing runs until the gate |
| 18 |
// below reports active, so an unconditional require here is inert with the |
| 19 |
// flag off. |
| 20 |
require_once __DIR__ . '/live-settings.php'; |
| 21 |
require_once __DIR__ . '/live-config.php'; |
| 22 |
require_once __DIR__ . '/live-connection.php'; |
| 23 |
require_once __DIR__ . '/live-entitlement.php'; |
| 24 |
require_once __DIR__ . '/live-params.php'; |
| 25 |
require_once __DIR__ . '/live-parse.php'; |
| 26 |
require_once __DIR__ . '/live-cache.php'; |
| 27 |
require_once __DIR__ . '/live-source.php'; |
| 28 |
require_once __DIR__ . '/live-map-reso.php'; |
| 29 |
require_once __DIR__ . '/live-grid.php'; |
| 30 |
require_once __DIR__ . '/live-single.php'; |
| 31 |
require_once __DIR__ . '/live-card.php'; |
| 32 |
require_once __DIR__ . '/live-map.php'; |
| 33 |
require_once __DIR__ . '/live-search-options.php'; |
| 34 |
require_once __DIR__ . '/live-selection.php'; |
| 35 |
require_once __DIR__ . '/live-guards.php'; |
| 36 |
|
| 37 |
/** |
| 38 |
* The single live-mode gate. Every live callback and guard checks this and |
| 39 |
* nothing else: standalone (990) ∧ flag on ∧ usable config ∧ credentials ∧ |
| 40 |
* subscription entitlement. |
| 41 |
* |
| 42 |
* @return bool |
| 43 |
*/ |
| 44 |
function mlsimport_live_mode_active(): bool { |
| 45 |
// All conditions must hold for live mode to engage. Short-circuit && means |
| 46 |
// each cheap/local check runs before the more expensive ones. |
| 47 |
$active = function_exists( 'mlsimport_is_standalone_mode' ) // standalone helper is loaded |
| 48 |
&& mlsimport_is_standalone_mode() // running in standalone (theme_id 990) |
| 49 |
&& mlsimport_live_enabled() // the live-mode setting flag is on |
| 50 |
&& array() !== mlsimport_live_config() // a usable per-MLS config exists |
| 51 |
&& mlsimport_live_credentials_present() // provider credentials are saved |
| 52 |
&& mlsimport_live_entitled(); // subscription entitlement is active |
| 53 |
|
| 54 |
/** Filter whether live MLS mode is active. @since 6.4 */ |
| 55 |
// Let integrations force the gate on/off; cast keeps the return strictly bool. |
| 56 |
return (bool) apply_filters( 'mlsimport_live_mode_active', $active ); |
| 57 |
} |
| 58 |
|
| 59 |
// Live Mode is not ready for release — the settings screen is hidden so the |
| 60 |
// feature cannot be enabled or used. Re-enable this line to bring it back. |
| 61 |
// add_action( 'admin_menu', 'mlsimport_live_settings_menu', 30 ); |
| 62 |
add_action( 'admin_notices', 'mlsimport_live_entitlement_notice' ); |
| 63 |
|