Files
2meet-data-optimizer/includes/class-tmdo-compatibility.php
T
wpdev 8a1c9c0353 refactor(2meet-data-optimizer): remove HPCT legacy from core
- Feature flags keep only the live AddOn modules (wc_orders, latepoint) as ADDON_MODULES / addon_modules(); drop map_hpct_status() and the 7 HivePress HPCT modules whose interceptors were removed in PR-014
- Remove HPCT detection/notice (Compatibility, core), the admin HPCT import tab and status row, CLI import-hpct, the 7 advisor rules for dead modules, and the removed interceptors from COEXIST_WHITELIST
- Verify: NoHpctLegacyTest guard; core unit 635 / integration 449, HP 145/49, WC 10/22 OK; all sites have every module idle and never imported HPCT
- PR: PR-020c
2026-09-26 00:14:18 +08:00

83 lines
1.8 KiB
PHP

<?php
/**
* Plugin coexistence manager for WP Data Optimizer.
*
* @package WP_Data_Optimizer
*/
declare(strict_types=1);
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Plugin coexistence manager.
*
* Detects active plugins and determines whether WPDO should register
* its interceptors or defer to existing plugins.
*/
class TMDO_Compatibility {
/**
* Cached detection results.
*
* @var array
*/
private static array $detected = array();
/**
* Run all compatibility checks. Called once during TMDO_Core::run().
*
* @return array Detection results.
*/
public static function check(): array {
if ( ! empty( self::$detected ) ) {
return self::$detected;
}
self::$detected = array(
'hivepress' => self::is_hivepress_active(),
'woocommerce' => self::is_woocommerce_active(),
);
return self::$detected;
}
/**
* Can WPDO register zone-specific interceptors (hot/warm/cold/archive)?
*
* Zone interceptors are always safe to register — they operate on
* WPDO's own tables.
*/
public static function can_register_zone_hooks(): bool {
return true;
}
/**
* Is HivePress core active?
*/
public static function is_hivepress_active(): bool {
return class_exists( 'HivePress\Core' );
}
/**
* Is WooCommerce active?
*/
public static function is_woocommerce_active(): bool {
return class_exists( 'WooCommerce' );
}
/**
* Is LatePoint plugin active? (v2.5.0 M16 polish — for module detector.)
*
* LatePoint exposes the OsBookingHelper class and `latepoint_*` action
* hooks. Detect via either the helper class or the version constant.
*/
public static function is_latepoint_active(): bool {
return class_exists( 'OsBookingHelper' )
|| defined( 'LATEPOINT_VERSION' )
|| function_exists( 'latepoint_get_settings' );
}
}