chore: initial snapshot of 2meet-data-optimizer-spoke-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:
2026-07-31 05:06:36 +08:00
commit 265bd14903
16 changed files with 2890 additions and 0 deletions
+57
View File
@@ -0,0 +1,57 @@
<?php
/**
* Bootstrap for 2meet Data Optimizer Spoke SSO AddOn.
*
* 負責 spoke-sso 對 2meet-data-optimizer 反 EAV 引擎的 schema 整合:
* - 註冊 user entity group `sso`7 欄位 → wp_wpdo_user_sso flat table
* - 註冊 spoke-sso 2 張自訂表(2mso_sso_config / 2mso_user_mapping
* - 提供 spoke-sync / spoke-force-logout CLI
*
* @package TMDO_SPOKE
* @since 0.1.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
require_once TMDO_SPOKE_PATH . 'includes/class-tmdo-spoke-sso-group.php';
require_once TMDO_SPOKE_PATH . 'includes/class-tmdo-spoke-custom-tables.php';
final class TMDO_Spoke_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-spoke',
false,
dirname( plugin_basename( TMDO_SPOKE_FILE ) ) . '/languages'
);
add_action( 'tmdo_register_entity_fields', array( 'TMDO_Spoke_SSO_Group', 'register' ), 10, 1 );
add_action( 'wpdo_register_entity_fields', array( 'TMDO_Spoke_SSO_Group', 'register' ), 10, 1 );
add_action( 'tmdo_register_custom_tables', array( 'TMDO_Spoke_Custom_Tables', 'register' ), 10, 1 );
add_action( 'wpdo_register_custom_tables', array( 'TMDO_Spoke_Custom_Tables', 'register' ), 10, 1 );
// CLI 命令延後到 cli initclass WP_CLI 存在時)
if ( defined( 'WP_CLI' ) && WP_CLI ) {
require_once TMDO_SPOKE_PATH . 'cli/class-tmdo-spoke-cli.php';
\WP_CLI::add_command( 'tmdo spoke-sync', array( 'TMDO_Spoke_CLI', 'sync' ) );
\WP_CLI::add_command( 'tmdo spoke-force-logout', array( 'TMDO_Spoke_CLI', 'force_logout' ) );
// 向後相容:對外仍提供 wp wpdo spoke-* 路徑。
\WP_CLI::add_command( 'wpdo spoke-sync', array( 'TMDO_Spoke_CLI', 'sync' ) );
\WP_CLI::add_command( 'wpdo spoke-force-logout', array( 'TMDO_Spoke_CLI', 'force_logout' ) );
}
}
public static function missing_core_notice(): void {
echo '<div class="notice notice-error"><p>';
echo esc_html__( '2meet Data Optimizer Spoke AddOn 需要 2meet-data-optimizer 核心外掛,請先安裝並啟用。', 'tmdo-spoke' );
echo '</p></div>';
}
}