feat(2meet-data-optimizer): warn when HivePress / WooCommerce run without their AddOn
- TMDO_Compatibility::missing_integration_addons() reports active HivePress / WooCommerce whose AddOn bootstrap class is absent - Surface it as Site Health test wpdo_missing_integration_addons (also on the admin Doctor tab) and an administrator notice (TMDO_Missing_Addons_Notice) - Verify: MissingIntegrationAddonsTest (5, class stand-ins in separate processes); core unit 651 / integration 449, HP 148, WC 10 OK; read-only check: dev20/21 HivePress+WooCommerce, dev22 HivePress, others clean - PR: PR-035
This commit is contained in:
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
/**
|
||||
* Admin notice when HivePress / WooCommerce run without their AddOn.
|
||||
*
|
||||
* Core knows nothing about either plugin; their fields are only optimised by
|
||||
* the matching AddOn. Without it, aeav_only data stays readable only through
|
||||
* the orphan-group restore, and new data is not optimised at all.
|
||||
*
|
||||
* @package WP_Data_Optimizer
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Warns administrators about integrations whose AddOn is not active.
|
||||
*/
|
||||
final class TMDO_Missing_Addons_Notice {
|
||||
|
||||
/**
|
||||
* Hook the notice.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function register(): void {
|
||||
add_action( 'admin_notices', array( __CLASS__, 'render' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Print the notice for administrators when an integration lacks its AddOn.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function render(): void {
|
||||
if ( ! current_user_can( 'manage_options' ) ) {
|
||||
return;
|
||||
}
|
||||
$missing = TMDO_Compatibility::missing_integration_addons();
|
||||
if ( empty( $missing ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$lines = array();
|
||||
foreach ( $missing as $plugin => $addon ) {
|
||||
$lines[] = sprintf( '%s → %s', $plugin, $addon );
|
||||
}
|
||||
printf(
|
||||
'<div class="notice notice-warning"><p><strong>%s</strong> %s</p></div>',
|
||||
esc_html__( '2meet Data Optimizer:', '2meet-data-optimizer' ),
|
||||
esc_html(
|
||||
sprintf(
|
||||
/* translators: %s: "Plugin → AddOn" pairs */
|
||||
__( '以下外掛已啟用,但對應的 AddOn 沒有啟用,它們的欄位不會被優化:%s。請啟用對應的 AddOn。', '2meet-data-optimizer' ),
|
||||
implode( ';', $lines )
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user