fix(bootstrap): 舊外掛互斥偵測改查 active_plugins

WPDO_VERSION 由 class-tmdo-back-compat.php 自行 define 為 TMDO_VERSION,
兩者永遠相等,admin notice 從未觸發;PHPStan L6 認出 notIdentical.alwaysFalse
並卡掉 main run #8 與 v1.0.0 tag 的 Test Gate。改查 active_plugins basename,
與 HP AddOn detector 的偵測方式一致。
This commit is contained in:
2026-07-31 09:50:23 +08:00
parent fbe41e2130
commit fee164d404
+5 -1
View File
@@ -88,7 +88,11 @@ if ( version_compare( PHP_VERSION, TMDO_MIN_PHP, '<' ) ) {
add_action(
'admin_notices',
static function () {
if ( defined( 'WPDO_VERSION' ) && WPDO_VERSION !== TMDO_VERSION ) {
// Deliberately not a WPDO_VERSION comparison: this plugin defines that
// constant itself (includes/class-tmdo-back-compat.php), so the two
// would always match and the notice could never fire.
$tmdo_legacy = 'wp-data-optimizer/wp-data-optimizer.php';
if ( in_array( $tmdo_legacy, (array) get_option( 'active_plugins', array() ), true ) ) {
echo '<div class="notice notice-error"><p>';
esc_html_e( '⚠ 偵測到舊版 wp-data-optimizer 已啟用。請停用舊外掛以避免 hook 雙觸發。', '2meet-data-optimizer' );
echo '</p></div>';