c70dc99bf9
- TMDO_Member_Fields no longer registers user/sso; the definition moved unchanged (hash 03543f19) to 2meet-data-optimizer-sso-addon. - missing_integration_addons(): 2meet-hub-core or 2meet-spoke-sso without the SSO AddOn is reported (admin notice + Site Health). - The deprecated-AddOn notice points hub / spoke users to the SSO AddOn. - Sites must activate the SSO AddOn before this ships (PR-041); aeav_only sites without it fall back to orphan-group restore. - Verify: core unit 659 / integration 475, SSO 6, HP 142/49, WC 10/22 green, phpcs clean - PR: PR-040
107 lines
2.8 KiB
PHP
107 lines
2.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' );
|
|
}
|
|
|
|
/**
|
|
* 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';
|
|
}
|
|
// 2meet-hub-core / 2meet-spoke-sso read and write the user `sso` group it owns.
|
|
if ( ( class_exists( 'TMHC_Plugin', false ) || class_exists( 'TMSO_Plugin', false ) ) && ! class_exists( 'TMDO_SSO_Integration', false ) ) {
|
|
$missing['2meet Hub / Spoke SSO'] = '2meet-data-optimizer-sso-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' );
|
|
}
|
|
}
|