Files
2meet-data-optimizer/includes/class-tmdo-compatibility.php
T
wpdev ecf4ff4938 refactor(2meet-data-optimizer): retire the SSO AddOn recommendation
- missing_integration_addons() no longer asks for the SSO AddOn when
  2meet-hub-core / 2meet-spoke-sso are active: they register their own
  tables and the `sso` values belong in usermeta (benchmark: no
  measurable gain from the flat table for by-user-id access).
- `sso` joins the deprecated AddOns; for hub / spoke / sso the notice says
  they go without replacement and to run
  `wp tmdo bridge-restore-native user --group=sso --retire` first.
- Verify: core unit 658 / integration 479 green, phpcs clean
- PR: PR-043
2026-09-26 04:07:40 +08:00

103 lines
2.5 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' );
}
/**
* Integrations that are active while their AddOn is not.
*
* Core does not know these plugins; their fields are only optimised by the
* matching AddOn. The AddOn is detected by its bootstrap class, which its
* main file declares as soon as the plugin loads.
*
* @return array<string, string> Plugin name → AddOn plugin slug.
*/
public static function missing_integration_addons(): array {
$missing = array();
if ( self::is_hivepress_active() && ! class_exists( 'TMDO_HP_Bootstrap' ) ) {
$missing['HivePress'] = '2meet-data-optimizer-hivepress-addon';
}
if ( self::is_woocommerce_active() && ! class_exists( 'TMDO_Woocommerce_Bootstrap' ) ) {
$missing['WooCommerce'] = '2meet-data-optimizer-woocommerce-addon';
}
return $missing;
}
/**
* 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' );
}
}