3d650eb848
- Add docs/PARTNER-REGISTRATION.md: TMDO_Anti_EAV_Aware bridge setup (plugins_loaded:3), table and entity-group registration with post_types scopes, frozen definitions, and the AddOn → self-registration migration checked with [COLLISION]/[ORPHAN] - TMDO_Deprecated_Addons_Notice warns administrators while any of the 8 in-house partner AddOns is active (site or network) - Trait register_entity_fields() forwards an optional $args (post_types) to the registry - Verify: DeprecatedAddonsNoticeTest (4); core unit 645 / integration 449, HP 148, WC 10 OK - PR: PR-021
84 lines
2.6 KiB
PHP
84 lines
2.6 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.
|
||
*
|
||
* @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' );
|
||
|
||
/**
|
||
* 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' )
|
||
);
|
||
}
|
||
}
|