chore: initial snapshot of 2meet-data-optimizer-hub-addon v0.1.0
Baseline before backporting wp-data-optimizer v3.0.1-v3.4.6. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TbG1keQQ7XBa7qMQY16KCY
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
/**
|
||||
* Bootstrap for 2meet Data Optimizer Hub AddOn.
|
||||
*
|
||||
* 負責 hub-core 對 2meet-data-optimizer 反 EAV 引擎的 schema 整合:
|
||||
* - 註冊 `_2meet_global_vendor_id` postmeta 到 cold zone (hp_vendor)
|
||||
* - 將 hub-core 12 張自訂表註冊到 TMDO Custom Table Registry(享有 doctor + drift 偵測)
|
||||
*
|
||||
* @package TMDO_HUB
|
||||
* @since 0.1.0
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
require_once TMDO_HUB_PATH . 'includes/class-tmdo-hub-vendor-field.php';
|
||||
require_once TMDO_HUB_PATH . 'includes/class-tmdo-hub-custom-tables.php';
|
||||
|
||||
final class TMDO_Hub_Bootstrap {
|
||||
|
||||
public static function init(): void {
|
||||
if ( ! class_exists( 'TMDO_API' ) && ! class_exists( 'WPDO_API' ) ) {
|
||||
add_action( 'admin_notices', array( __CLASS__, 'missing_core_notice' ) );
|
||||
return;
|
||||
}
|
||||
|
||||
load_plugin_textdomain(
|
||||
'tmdo-hub',
|
||||
false,
|
||||
dirname( plugin_basename( TMDO_HUB_FILE ) ) . '/languages'
|
||||
);
|
||||
|
||||
// 接 tmdo_* 與 wpdo_* 雙向相容(核心 dual-fire 已配對,但這裡兩邊掛 callback 不會重複觸發
|
||||
// — class 內部以 static $registered guard 確保 idempotent)。
|
||||
add_action( 'tmdo_register_fields', array( 'TMDO_Hub_Vendor_Field', 'register' ), 10, 1 );
|
||||
add_action( 'wpdo_register_fields', array( 'TMDO_Hub_Vendor_Field', 'register' ), 10, 1 );
|
||||
|
||||
add_action( 'tmdo_register_custom_tables', array( 'TMDO_Hub_Custom_Tables', 'register' ), 10, 1 );
|
||||
add_action( 'wpdo_register_custom_tables', array( 'TMDO_Hub_Custom_Tables', 'register' ), 10, 1 );
|
||||
}
|
||||
|
||||
public static function missing_core_notice(): void {
|
||||
echo '<div class="notice notice-error"><p>';
|
||||
echo esc_html__( '2meet Data Optimizer Hub AddOn 需要 2meet-data-optimizer 核心外掛,請先安裝並啟用。', 'tmdo-hub' );
|
||||
echo '</p></div>';
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user