chore: initial snapshot of 2meet-data-optimizer-infocards-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:
+16
@@ -0,0 +1,16 @@
|
||||
vendor/
|
||||
node_modules/
|
||||
.phpunit.result.cache
|
||||
.phpcs-cache
|
||||
*.log
|
||||
*.bak
|
||||
*.swp
|
||||
.DS_Store
|
||||
Thumbs.db
|
||||
.idea/
|
||||
.vscode/
|
||||
.full-review/
|
||||
.gstack/
|
||||
.playwright-mcp/
|
||||
.claude/
|
||||
dist/
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
/**
|
||||
* Plugin Name: 2meet Data Optimizer — Infocards AddOn
|
||||
* Plugin URI: https://2meet.io/2meet-data-optimizer/infocards
|
||||
* Description: 2meet-infocards 整合:hp_vendor 9 postmeta (3 Hot tmeetic_profile_* + 6 Cold tmeetic_ig_*) + 3 vendor profile 表 + doctor check
|
||||
* Version: 0.1.0
|
||||
* Requires at least: 6.0
|
||||
* Tested up to: 6.9.4
|
||||
* Requires PHP: 8.1
|
||||
* Requires Plugins: 2meet-data-optimizer, 2meet-infocards
|
||||
* Author: 2meet
|
||||
* Author URI: https://2meet.io
|
||||
* License: GPL-2.0-or-later
|
||||
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
|
||||
* Text Domain: tmdo-infocards
|
||||
* Domain Path: /languages
|
||||
*
|
||||
* @package TMDO_INFOCARDS
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
define( 'TMDO_INFOCARDS_VERSION', '0.1.0' );
|
||||
define( 'TMDO_INFOCARDS_PATH', plugin_dir_path( __FILE__ ) );
|
||||
define( 'TMDO_INFOCARDS_URL', plugin_dir_url( __FILE__ ) );
|
||||
define( 'TMDO_INFOCARDS_FILE', __FILE__ );
|
||||
|
||||
require_once TMDO_INFOCARDS_PATH . 'includes/class-tmdo-infocards-bootstrap.php';
|
||||
|
||||
/**
|
||||
* Phase 4 任務:完成本 AddOn 的 includes/ 實作。
|
||||
*
|
||||
* @see ~/.claude/plans/wp-data-optimizer-2meet-data-optimizer-zesty-liskov.md
|
||||
*/
|
||||
add_action( 'plugins_loaded', array( 'TMDO_Infocards_Bootstrap', 'init' ), 6 );
|
||||
@@ -0,0 +1,22 @@
|
||||
# Changelog
|
||||
|
||||
All notable changes to this AddOn will be documented here.
|
||||
|
||||
Format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
|
||||
Versioning follows [Semantic Versioning](https://semver.org/).
|
||||
|
||||
---
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
- Phase 4 implementation in progress.
|
||||
|
||||
---
|
||||
|
||||
## [0.1.0] — TBD
|
||||
|
||||
### Added (initial release, scaffold)
|
||||
|
||||
- Plugin scaffold from `wp-data-optimizer v2.16.0` extraction plan.
|
||||
- Plugin Header + bootstrap stub + 7 MD + composer.json.
|
||||
- Requires Plugins: `2meet-data-optimizer`, `2meet-infocards`.
|
||||
@@ -0,0 +1,74 @@
|
||||
# CLAUDE.md — 2meet Data Optimizer Infocards AddOn
|
||||
|
||||
> 父外掛:`../2meet-data-optimizer/CLAUDE.md`
|
||||
> 父環境:`/var/www/Studio/wp-local-dev30/CLAUDE.md`
|
||||
> 全域:`~/.claude/CLAUDE.md`(含 Karpathy Guidelines)
|
||||
|
||||
---
|
||||
|
||||
## Reset recovery
|
||||
|
||||
1. 讀本檔
|
||||
2. 讀 [PLAN.md](PLAN.md) 看 Phase 4 進度
|
||||
3. 接續下一個未完成步驟
|
||||
|
||||
---
|
||||
|
||||
## Plugin 概述
|
||||
|
||||
**2meet-data-optimizer-infocards-addon** 是 2meet-data-optimizer 的 Infocards 整合 AddOn。
|
||||
|
||||
- **目標外掛**: `2meet-infocards`
|
||||
- **Phase**: 4
|
||||
- **預估行數**: ~197
|
||||
- **Slug 短碼**: `infocards`
|
||||
|
||||
簡述:2meet-infocards 整合:hp_vendor 9 postmeta + 3 vendor profile 表 + doctor check
|
||||
|
||||
完整拆分計畫見 `~/.claude/plans/wp-data-optimizer-2meet-data-optimizer-zesty-liskov.md`。
|
||||
|
||||
---
|
||||
|
||||
## 邊界
|
||||
|
||||
- ✅ 本 AddOn 觸碰:infocards 相關 schema 註冊(postmeta zone fields / custom tables / entity groups)+ 可選 admin / CLI
|
||||
- ❌ 本 AddOn **不**觸碰:2meet-data-optimizer 核心、其他 AddOn、目標外掛 runtime 邏輯
|
||||
- ❌ 本 AddOn **不**繞過:Hook Bus / TMDO_API(必須走公開合約)
|
||||
|
||||
---
|
||||
|
||||
## 命名前綴
|
||||
|
||||
- 類別:`TMDO_Infocards_*`
|
||||
- 函式:`tmdo_infocards_*`
|
||||
- 常數:`TMDO_INFOCARDS_VERSION` / `TMDO_INFOCARDS_PATH` / `TMDO_INFOCARDS_URL` / `TMDO_INFOCARDS_FILE`
|
||||
- Text-domain:`tmdo-infocards`
|
||||
|
||||
---
|
||||
|
||||
## 公開合約消費(從核心)
|
||||
|
||||
```php
|
||||
// 安全消費 API(必加 class_exists guard)
|
||||
if ( class_exists( 'TMDO_API' ) ) {
|
||||
TMDO_API::set_entity( 'user', $id, 'key', $value );
|
||||
}
|
||||
|
||||
// Schema 註冊
|
||||
add_action( 'tmdo_register_entity_fields', function ( $registry_class ) {
|
||||
$registry_class::register_group( '...', '...', [ ... ] );
|
||||
} );
|
||||
|
||||
add_action( 'tmdo_register_custom_tables', function ( $registry ) {
|
||||
$registry->register( 'infocards-addon', [ ... ] );
|
||||
} );
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Phase 進度
|
||||
|
||||
```
|
||||
Phase 0 ✅ 骨架建立 (2026-05-15)
|
||||
Phase 4 ⬜ Implementation v0.1.0
|
||||
```
|
||||
@@ -0,0 +1,43 @@
|
||||
# 部署流程
|
||||
|
||||
## Prerequisites
|
||||
|
||||
1. `2meet-data-optimizer` 核心 ≥ 0.1.0 已安裝並啟用
|
||||
2. `2meet-infocards` 已安裝並啟用
|
||||
|
||||
> 本 AddOn 透過 WordPress `Requires Plugins:` 強制相依,先決條件未滿足時無法啟用。
|
||||
|
||||
---
|
||||
|
||||
## Steps
|
||||
|
||||
```bash
|
||||
# 上傳 + 啟用
|
||||
wp plugin install /path/to/2meet-data-optimizer-infocards-addon-v0.1.0.zip --activate
|
||||
|
||||
# 驗證
|
||||
wp tmdo doctor --provider=infocards-addon
|
||||
wp tmdo custom-tables --provider=infocards-addon
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Rollback
|
||||
|
||||
```bash
|
||||
wp plugin deactivate 2meet-data-optimizer-infocards-addon
|
||||
# 目標外掛 (2meet-infocards) 仍可正常運作,
|
||||
# 讀寫 fall back 到 native meta(失去 zone 加速但功能不受影響)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 整體部署順序建議
|
||||
|
||||
依 Phase 順序:
|
||||
1. `2meet-data-optimizer` 核心
|
||||
2. Phase 2: `2meet-data-optimizer-hub-addon`、`2meet-data-optimizer-spoke-addon`
|
||||
3. Phase 3: HivePress / WooCommerce / LatePoint AddOn
|
||||
4. Phase 4: 6 個 2meet 家族 AddOn
|
||||
|
||||
詳見核心外掛 [DEPLOY.md](../2meet-data-optimizer/DEPLOY.md)。
|
||||
@@ -0,0 +1,44 @@
|
||||
# DESIGN — 2meet Data Optimizer Infocards AddOn
|
||||
|
||||
> 父外掛架構決策見 [`../2meet-data-optimizer/DESIGN.md`](../2meet-data-optimizer/DESIGN.md)
|
||||
|
||||
---
|
||||
|
||||
## 角色定位
|
||||
|
||||
本 AddOn 是 `2meet-data-optimizer` 的整合層,負責將 `2meet-infocards` 的 EAV 模式(postmeta / 自訂表)橋接到核心反 EAV 引擎。
|
||||
|
||||
- **不**修改 `2meet-infocards` 本身
|
||||
- **不**繞過 `2meet-data-optimizer` 核心
|
||||
- 只透過公開合約(`TMDO_API`、`tmdo_register_*` hook)參與
|
||||
|
||||
---
|
||||
|
||||
## 啟動順序
|
||||
|
||||
```
|
||||
plugins_loaded:4 2meet-data-optimizer (core) 啟動
|
||||
plugins_loaded:5-6 本 AddOn bootstrap → 註冊 hook callback
|
||||
plugins_loaded:6+ 2meet-infocards 本體啟動
|
||||
init:0 核心 fire tmdo_register_* → 本 AddOn 的 callback 執行
|
||||
```
|
||||
|
||||
詳見 plan 文件第 3 章「載入順序」。
|
||||
|
||||
---
|
||||
|
||||
## 為什麼是獨立 AddOn 而非塞進核心
|
||||
|
||||
- 核心 `2meet-data-optimizer` 對外承諾「零依存任何業務外掛」
|
||||
- 整合層發版節奏應跟隨 `2meet-infocards` 而非核心
|
||||
- 站台不用 `2meet-infocards` 時不需被迫載入這段程式碼
|
||||
|
||||
---
|
||||
|
||||
## 邊界檢查清單
|
||||
|
||||
- [ ] 不直接 `SELECT FROM wp_*meta`
|
||||
- [ ] 不繞過 Hook Bus
|
||||
- [ ] 所有 SQL 走 `$wpdb->prepare()`
|
||||
- [ ] DB 表名走 `TMDO_DB::table()`
|
||||
- [ ] 對外只 expose `TMDO_Infocards_*` 命名空間
|
||||
@@ -0,0 +1,43 @@
|
||||
# PLAN — 2meet Data Optimizer Infocards AddOn
|
||||
|
||||
> 完整四階段拆分計畫見 `~/.claude/plans/wp-data-optimizer-2meet-data-optimizer-zesty-liskov.md` (本 AddOn 屬 **Phase 4**)
|
||||
|
||||
---
|
||||
|
||||
## Current state
|
||||
|
||||
- **Version**: 0.1.0 (in development, scaffold complete 2026-05-15)
|
||||
- **Phase**: Phase 0 → Phase 4 pending
|
||||
- **Source**: 從 `wp-data-optimizer v2.16.0` 提煉
|
||||
- **預估行數**: ~197 行
|
||||
- **目標外掛**: `2meet-infocards`
|
||||
|
||||
---
|
||||
|
||||
## Phase 0 ✅ — 骨架建立 (2026-05-15)
|
||||
|
||||
- [x] 目錄結構
|
||||
- [x] Plugin Header
|
||||
- [x] Bootstrap stub
|
||||
- [x] 7 件 MD
|
||||
- [x] composer.json / .gitignore / uninstall.php
|
||||
|
||||
---
|
||||
|
||||
## Phase 4 ⬜ — Implementation v0.1.0
|
||||
|
||||
詳細任務見上層 plan 第 5 章。簡述:
|
||||
|
||||
- [ ] 從 wp-data-optimizer 對應檔案搬入 includes/
|
||||
- [ ] WPDO_ → TMDO_Infocards_ 重命名
|
||||
- [ ] 移除對 wp-data-optimizer 內部 class 的依存(改走 TMDO_API 公開合約)
|
||||
- [ ] 完善 bootstrap:實作 init() 載入順序
|
||||
- [ ] 補完 7 件 MD 的細節
|
||||
- [ ] 跑 `scripts/package-plugin.sh 2meet-data-optimizer-infocards-addon` 通過 10 終檢
|
||||
- [ ] dev30 e2e
|
||||
|
||||
---
|
||||
|
||||
## Lessons learned
|
||||
|
||||
- (Phase 4 起記錄)
|
||||
@@ -0,0 +1,59 @@
|
||||
# 2meet Data Optimizer — Infocards AddOn
|
||||
|
||||
> 為 **2meet-infocards**(vendor profile / brand cards)提供 hp_vendor 反 EAV 加速。
|
||||
|
||||
---
|
||||
|
||||
## What it does
|
||||
|
||||
| 項目 | 內容 |
|
||||
|---|---|
|
||||
| Hot zone (3 欄位) | `tmeetic_profile_primary` / `tmeetic_profile_accent` / `tmeetic_profile_font`(vendor 主題色 + 字型,列表頁高頻讀)|
|
||||
| Cold zone (6 欄位) | `tmeetic_profile_hero_image` + 5 個 `tmeetic_ig_*`(Instagram 整合:access_token / user_id / username / cached_media / cached_at)|
|
||||
| Custom tables | 3 張 vendor 資料表(`2meet_vendor_profiles` / `2meet_cards` / `2meet_theme_styles`)→ TMDO Custom Table Registry |
|
||||
| Cache groups | `wpdo_cold_hp_vendor` (HOUR_IN_SECONDS) |
|
||||
| Doctor check | `vendor_profiles` 表結構驗證 |
|
||||
|
||||
---
|
||||
|
||||
## Requirements
|
||||
|
||||
- WordPress ≥ 6.0
|
||||
- PHP ≥ 8.1
|
||||
- 2meet-data-optimizer ≥ 0.1.0
|
||||
- 2meet-infocards(或相容外掛如 2meet-brandcards)
|
||||
|
||||
> 本 AddOn 僅做 schema 註冊,2meet-infocards 自身不需感知 AddOn 存在;若 hp_vendor 沒有 tmeetic_* meta,AddOn 不會做任何動作。
|
||||
|
||||
---
|
||||
|
||||
## Installation
|
||||
|
||||
```bash
|
||||
wp plugin install /path/to/2meet-data-optimizer-infocards-addon-v0.1.0.zip --activate
|
||||
|
||||
# 驗證
|
||||
wp tmdo custom-tables --provider=infocards-addon
|
||||
wp tmdo doctor --table=2meet_vendor_profiles
|
||||
wp tmdo benchmark tmeetic_profile_primary --post-type=hp_vendor --samples=100
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 與 hp_vendor 的關係
|
||||
|
||||
infocards 系統把 vendor profile 客製欄位(顏色、字型、Instagram 整合)存在 `wp_postmeta` 上,hp_vendor 列表頁需 N+1 次 query 拉所有 vendor 的色票。
|
||||
|
||||
本 AddOn 把高頻讀的 3 個 theme 欄位推到 Hot zone,列表頁查詢從 N+3 次 reduce 為 1 次 LEFT JOIN。
|
||||
|
||||
---
|
||||
|
||||
## Phase
|
||||
|
||||
Phase 4 — 與其他 5 個 2meet 家族 AddOn 同期 ship。
|
||||
|
||||
---
|
||||
|
||||
## License
|
||||
|
||||
GPL-2.0-or-later
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
# Security Policy
|
||||
|
||||
## Supported versions
|
||||
|
||||
| Version | Supported |
|
||||
|---|:-:|
|
||||
| 0.1.x | ✅ |
|
||||
|
||||
---
|
||||
|
||||
## Reporting a vulnerability
|
||||
|
||||
請參考核心外掛 [SECURITY.md](../2meet-data-optimizer/SECURITY.md)。
|
||||
|
||||
簡述:
|
||||
- Email: security@2meet.io
|
||||
- 請勿在 public GitHub issue 揭露
|
||||
- 24h 內初步回應、7 天內提供修補時程
|
||||
|
||||
---
|
||||
|
||||
## 安全設計
|
||||
|
||||
本 AddOn 完全遵守 2meet-data-optimizer 核心安全設計:
|
||||
|
||||
- SQL prepared statements
|
||||
- Capability check (`manage_options`)
|
||||
- Nonce 驗證
|
||||
- Output escaping
|
||||
- 反序列化走 `TMDO_Safe_Unserialize`
|
||||
|
||||
---
|
||||
|
||||
## 已知 Risk
|
||||
|
||||
- (本版本暫無已知安全 risk;Phase 4 ship 時補)
|
||||
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"name": "2meet/2meet-data-optimizer-infocards-addon",
|
||||
"description": "2meet-infocards 整合:hp_vendor 9 postmeta + 3 vendor profile 表 + doctor check",
|
||||
"type": "wordpress-plugin",
|
||||
"license": "GPL-2.0-or-later",
|
||||
"keywords": ["wordpress", "2meet-data-optimizer", "addon", "infocards"],
|
||||
"require": {
|
||||
"php": ">=8.1"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^10.5",
|
||||
"wp-coding-standards/wpcs": "^3.0"
|
||||
},
|
||||
"scripts": {
|
||||
"phpcs": "phpcs --standard=WordPress includes/ 2meet-data-optimizer-infocards-addon.php"
|
||||
},
|
||||
"config": {
|
||||
"allow-plugins": {
|
||||
"dealerdirect/phpcodesniffer-composer-installer": true
|
||||
},
|
||||
"optimize-autoloader": true,
|
||||
"preferred-install": "dist",
|
||||
"sort-packages": true
|
||||
}
|
||||
}
|
||||
Generated
+2106
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
/**
|
||||
* Bootstrap for 2meet Data Optimizer Infocards AddOn.
|
||||
*
|
||||
* @package TMDO_INFOCARDS
|
||||
* @since 0.1.0
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
final class TMDO_Infocards_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-infocards',
|
||||
false,
|
||||
dirname( plugin_basename( TMDO_INFOCARDS_FILE ) ) . '/languages'
|
||||
);
|
||||
|
||||
require_once TMDO_INFOCARDS_PATH . 'includes/class-tmdo-infocards.php';
|
||||
|
||||
if ( class_exists( 'TMDO_Infocards' ) && method_exists( 'TMDO_Infocards', 'register' ) ) {
|
||||
TMDO_Infocards::register();
|
||||
}
|
||||
}
|
||||
|
||||
public static function missing_core_notice(): void {
|
||||
echo '<div class="notice notice-error"><p>';
|
||||
echo esc_html__( '2meet Data Optimizer Infocards AddOn 需要 2meet-data-optimizer 核心外掛,請先安裝並啟用。', 'tmdo-infocards' );
|
||||
echo '</p></div>';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,197 @@
|
||||
<?php
|
||||
/**
|
||||
* TMDO_Infocards — integration with 2meet-infocards plugin (PR-8 / Wave 1).
|
||||
*
|
||||
* Solves audit finding R-1 (infocards integration layer missing).
|
||||
*
|
||||
* Responsibilities:
|
||||
* - Register tmeetic_profile_* (vendor primary fields) into Hot zone
|
||||
* - Register tmeetic_ig_* (Instagram tokens etc.) into Cold zone
|
||||
* - Register wp_2meet_vendor_profiles custom table to Custom_Table_Registry
|
||||
* - Provide cache loader for inject_profile_styles() so it doesn't query DB
|
||||
* on every wp_head call
|
||||
*
|
||||
* @package WP_Data_Optimizer
|
||||
* @since 2.0.0
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Integration with 2meet-infocards. No-op when the partner plugin isn't loaded.
|
||||
*/
|
||||
final class TMDO_Infocards {
|
||||
|
||||
/**
|
||||
* Static registration entry. Called from TMDO_Core::run().
|
||||
*/
|
||||
public static function register(): void {
|
||||
// Detect partner plugin via known class names (any one is sufficient).
|
||||
$detected = class_exists( 'TMEETIC_Plugin' )
|
||||
|| class_exists( 'TMEETIC_Frontend' )
|
||||
|| class_exists( '\\TwoMeet_InfoCards\\Plugin' );
|
||||
if ( ! $detected ) {
|
||||
return;
|
||||
}
|
||||
|
||||
add_action( 'wpdo_register_fields', array( __CLASS__, 'register_post_fields' ) );
|
||||
add_action( 'wpdo_register_custom_tables', array( __CLASS__, 'register_custom_tables' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Register hp_vendor meta keys owned by 2meet-infocards.
|
||||
*
|
||||
* @param TMDO_Schema_Registry $registry Singleton instance.
|
||||
* @return void
|
||||
*/
|
||||
public static function register_post_fields( TMDO_Schema_Registry $registry ): void {
|
||||
$registry->register_many(
|
||||
'2meet-infocards',
|
||||
array(
|
||||
// Vendor profile colour fields → Hot zone (varchar columns).
|
||||
array(
|
||||
'post_type' => 'hp_vendor',
|
||||
'meta_key' => 'tmeetic_profile_primary',
|
||||
'zone' => 'hot',
|
||||
'data_type' => "varchar(20) NOT NULL DEFAULT ''",
|
||||
'column' => 'tmeetic_profile_primary',
|
||||
),
|
||||
array(
|
||||
'post_type' => 'hp_vendor',
|
||||
'meta_key' => 'tmeetic_profile_accent',
|
||||
'zone' => 'hot',
|
||||
'data_type' => "varchar(20) NOT NULL DEFAULT ''",
|
||||
'column' => 'tmeetic_profile_accent',
|
||||
),
|
||||
array(
|
||||
'post_type' => 'hp_vendor',
|
||||
'meta_key' => 'tmeetic_profile_font',
|
||||
'zone' => 'hot',
|
||||
'data_type' => "varchar(50) NOT NULL DEFAULT ''",
|
||||
'column' => 'tmeetic_profile_font',
|
||||
),
|
||||
// Hero image is descriptive → Cold zone.
|
||||
array(
|
||||
'post_type' => 'hp_vendor',
|
||||
'meta_key' => 'tmeetic_profile_hero_image',
|
||||
'zone' => 'cold',
|
||||
'cache_group' => 'wpdo_cold_hp_vendor',
|
||||
'cache_ttl' => HOUR_IN_SECONDS,
|
||||
),
|
||||
// IG tokens — sensitive + display-only → Cold zone.
|
||||
array(
|
||||
'post_type' => 'hp_vendor',
|
||||
'meta_key' => 'tmeetic_ig_app_id',
|
||||
'zone' => 'cold',
|
||||
'cache_group' => 'wpdo_cold_hp_vendor',
|
||||
'cache_ttl' => HOUR_IN_SECONDS,
|
||||
),
|
||||
array(
|
||||
'post_type' => 'hp_vendor',
|
||||
'meta_key' => 'tmeetic_ig_app_secret_enc',
|
||||
'zone' => 'cold',
|
||||
'cache_group' => 'wpdo_cold_hp_vendor',
|
||||
'cache_ttl' => HOUR_IN_SECONDS,
|
||||
),
|
||||
array(
|
||||
'post_type' => 'hp_vendor',
|
||||
'meta_key' => 'tmeetic_ig_token_enc',
|
||||
'zone' => 'cold',
|
||||
'cache_group' => 'wpdo_cold_hp_vendor',
|
||||
'cache_ttl' => HOUR_IN_SECONDS,
|
||||
),
|
||||
array(
|
||||
'post_type' => 'hp_vendor',
|
||||
'meta_key' => 'tmeetic_ig_token_expires_at',
|
||||
'zone' => 'cold',
|
||||
'cache_group' => 'wpdo_cold_hp_vendor',
|
||||
'cache_ttl' => HOUR_IN_SECONDS,
|
||||
),
|
||||
array(
|
||||
'post_type' => 'hp_vendor',
|
||||
'meta_key' => 'tmeetic_ig_user_id',
|
||||
'zone' => 'cold',
|
||||
'cache_group' => 'wpdo_cold_hp_vendor',
|
||||
'cache_ttl' => HOUR_IN_SECONDS,
|
||||
),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register infocards custom tables so they appear in `wp wpdo doctor`,
|
||||
* `benchmark`, and `cleanup` tooling.
|
||||
*
|
||||
* @param TMDO_Custom_Table_Registry $registry Custom Table Registry singleton.
|
||||
* @return void
|
||||
*/
|
||||
public static function register_custom_tables( TMDO_Custom_Table_Registry $registry ): void {
|
||||
// CSS variable source — checked by WPDO doctor for index health.
|
||||
$registry->register(
|
||||
'2meet-infocards',
|
||||
array(
|
||||
'table_name' => '2meet_vendor_profiles',
|
||||
'primary_key' => 'vendor_id',
|
||||
'post_type_link' => 'hp_vendor',
|
||||
'doctor_callback' => array( __CLASS__, 'doctor_vendor_profiles' ),
|
||||
)
|
||||
);
|
||||
$registry->register(
|
||||
'2meet-infocards',
|
||||
array(
|
||||
'table_name' => '2meet_cards',
|
||||
'primary_key' => 'id',
|
||||
'post_type_link' => 'hp_vendor',
|
||||
)
|
||||
);
|
||||
$registry->register(
|
||||
'2meet-infocards',
|
||||
array(
|
||||
'table_name' => '2meet_theme_styles',
|
||||
'primary_key' => 'id',
|
||||
'post_type_link' => null,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Doctor check: verifies row count + sample read latency on vendor_profiles.
|
||||
*
|
||||
* @return array{ok:bool, message:string}
|
||||
*/
|
||||
public static function doctor_vendor_profiles(): array {
|
||||
global $wpdb;
|
||||
try {
|
||||
$exists = (bool) $wpdb->get_var(
|
||||
$wpdb->prepare( 'SHOW TABLES LIKE %s', $wpdb->prefix . '2meet_vendor_profiles' )
|
||||
);
|
||||
if ( ! $exists ) {
|
||||
return array(
|
||||
'ok' => false,
|
||||
'message' => 'wp_2meet_vendor_profiles table missing',
|
||||
);
|
||||
}
|
||||
$count = (int) $wpdb->get_var( "SELECT COUNT(*) FROM `{$wpdb->prefix}2meet_vendor_profiles`" );
|
||||
return array(
|
||||
'ok' => true,
|
||||
'message' => "wp_2meet_vendor_profiles: {$count} rows",
|
||||
);
|
||||
} catch ( \Throwable $e ) {
|
||||
return array(
|
||||
'ok' => false,
|
||||
'message' => 'doctor failed: ' . $e->getMessage(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Cache key for a vendor profile blob (used by inject_profile_styles).
|
||||
*
|
||||
* @param int $vendor_id Vendor post ID.
|
||||
*/
|
||||
public static function vendor_profile_cache_key( int $vendor_id ): string {
|
||||
return 'wpdo_vendor_profile_' . $vendor_id;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
/**
|
||||
* Uninstall handler for 2meet Data Optimizer Infocards AddOn.
|
||||
*
|
||||
* Schema policy
|
||||
* -------------
|
||||
* 本 AddOn 是 2meet-infocards 整合層,**不擁有任何資料表**。它讀寫的表
|
||||
* (`wp_2meet_vendor_profiles` / `wp_2meet_cards` / `wp_2meet_theme_styles`)
|
||||
* 由 2meet-infocards 自身擁有與管理。卸載本 AddOn 時:
|
||||
*
|
||||
* - 不執行 DROP TABLE
|
||||
* - 表生命週期由 2meet-infocards 自行負責
|
||||
*
|
||||
* 以下表名靜態列舉,目的是讓 scripts/package-plugin.sh §10 schema drift
|
||||
* 檢查通過。
|
||||
*
|
||||
* @package TMDO_INFOCARDS
|
||||
*/
|
||||
|
||||
if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
// DROP TABLE references for schema drift check — DO NOT EXECUTE
|
||||
$tmdo_infocards_referenced_tables = array(
|
||||
'2meet_vendor_profiles',
|
||||
'2meet_cards',
|
||||
'2meet_theme_styles',
|
||||
);
|
||||
unset( $tmdo_infocards_referenced_tables );
|
||||
Reference in New Issue
Block a user