ecf4ff4938
- 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
92 lines
3.2 KiB
PHP
92 lines
3.2 KiB
PHP
<?php
|
||
/**
|
||
* Admin notice for the deprecated in-house partner AddOns.
|
||
*
|
||
* The AddOns for 2meet's own plugins (bookings, collab, hub, infocards,
|
||
* mobile-bridge, playlist, quotation, spoke) only registered tables and fields
|
||
* on the partner's behalf. Partner plugins now register themselves with the
|
||
* TMDO_Anti_EAV_Aware trait (docs/PARTNER-REGISTRATION.md), so these AddOns
|
||
* are deprecated and will be removed. The SSO data needs no AddOn at all:
|
||
* the hub, spoke and SSO AddOns go without replacement (the `sso` group gave
|
||
* no measurable gain over usermeta) once its values are written back.
|
||
*
|
||
* @package WP_Data_Optimizer
|
||
*/
|
||
|
||
declare(strict_types=1);
|
||
|
||
if ( ! defined( 'ABSPATH' ) ) {
|
||
exit;
|
||
}
|
||
|
||
/**
|
||
* Warns admins who still run one of the deprecated partner AddOns.
|
||
*/
|
||
final class TMDO_Deprecated_Addons_Notice {
|
||
|
||
/** In-house plugins whose AddOn is replaced by partner self-registration. */
|
||
private const SLUGS = array( 'bookings', 'collab', 'hub', 'infocards', 'mobile-bridge', 'playlist', 'quotation', 'spoke', 'sso' );
|
||
|
||
/**
|
||
* Hook the notice.
|
||
*
|
||
* @return void
|
||
*/
|
||
public static function register(): void {
|
||
add_action( 'admin_notices', array( __CLASS__, 'render' ) );
|
||
}
|
||
|
||
/**
|
||
* Slugs of the deprecated AddOns active on this site (or network-wide).
|
||
*
|
||
* @return string[]
|
||
*/
|
||
public static function active(): array {
|
||
$active = (array) get_option( 'active_plugins', array() );
|
||
if ( is_multisite() ) {
|
||
$active = array_merge( $active, array_keys( (array) get_site_option( 'active_sitewide_plugins', array() ) ) );
|
||
}
|
||
return array_values(
|
||
array_filter(
|
||
self::SLUGS,
|
||
static fn( string $slug ): bool => in_array( "2meet-data-optimizer-{$slug}-addon/2meet-data-optimizer-{$slug}-addon.php", $active, true )
|
||
)
|
||
);
|
||
}
|
||
|
||
/**
|
||
* Print the notice for administrators when any deprecated AddOn is active.
|
||
*
|
||
* @return void
|
||
*/
|
||
public static function render(): void {
|
||
if ( ! current_user_can( 'manage_options' ) ) {
|
||
return;
|
||
}
|
||
$active = self::active();
|
||
if ( empty( $active ) ) {
|
||
return;
|
||
}
|
||
|
||
$names = implode( ', ', array_map( static fn( string $slug ): string => "2meet-data-optimizer-{$slug}-addon", $active ) );
|
||
printf(
|
||
'<div class="notice notice-warning"><p><strong>%s</strong> %s</p><p>%s</p></div>',
|
||
esc_html__( '2meet Data Optimizer:', '2meet-data-optimizer' ),
|
||
esc_html(
|
||
sprintf(
|
||
/* translators: %s: comma-separated AddOn plugin slugs */
|
||
__( '以下 AddOn 已淘汰:%s。對應的 2meet 外掛改為自行向核心註冊資料表與欄位,AddOn 之後會移除。', '2meet-data-optimizer' ),
|
||
$names
|
||
)
|
||
),
|
||
esc_html__( '改寫方式見 2meet-data-optimizer 外掛內的 docs/PARTNER-REGISTRATION.md;partner 外掛完成自行註冊後即可停用對應 AddOn。', '2meet-data-optimizer' )
|
||
);
|
||
if ( array_intersect( $active, array( 'hub', 'spoke', 'sso' ) ) ) {
|
||
printf(
|
||
'<div class="notice notice-warning"><p>%s</p></div>',
|
||
esc_html__( 'Hub / Spoke / SSO AddOn 不需替代:2meet-hub-core 與 2meet-spoke-sso 會自行註冊資料表,SSO 值存回 usermeta 即可。停用前先執行 wp tmdo bridge-restore-native user --group=sso --retire。', '2meet-data-optimizer' )
|
||
);
|
||
}
|
||
}
|
||
}
|