chore: initial snapshot of 2meet-data-optimizer-quotation-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 — Quotation AddOn
|
||||
* Plugin URI: https://2meet.io/2meet-data-optimizer/quotation
|
||||
* Description: 2meet-quotation 8 張自訂表 (2mq_*) 註冊(含 hp_vendor post_type_link)
|
||||
* 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-quotation
|
||||
* 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-quotation
|
||||
* Domain Path: /languages
|
||||
*
|
||||
* @package TMDO_QUOTATION
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
define( 'TMDO_QUOTATION_VERSION', '0.1.0' );
|
||||
define( 'TMDO_QUOTATION_PATH', plugin_dir_path( __FILE__ ) );
|
||||
define( 'TMDO_QUOTATION_URL', plugin_dir_url( __FILE__ ) );
|
||||
define( 'TMDO_QUOTATION_FILE', __FILE__ );
|
||||
|
||||
require_once TMDO_QUOTATION_PATH . 'includes/class-tmdo-quotation-bootstrap.php';
|
||||
|
||||
/**
|
||||
* Phase 4 任務:完成本 AddOn 的 includes/ 實作。
|
||||
*
|
||||
* @see ~/.claude/plans/wp-data-optimizer-2meet-data-optimizer-zesty-liskov.md
|
||||
*/
|
||||
add_action( 'plugins_loaded', array( 'TMDO_Quotation_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-quotation`.
|
||||
@@ -0,0 +1,74 @@
|
||||
# CLAUDE.md — 2meet Data Optimizer Quotation 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-quotation-addon** 是 2meet-data-optimizer 的 Quotation 整合 AddOn。
|
||||
|
||||
- **目標外掛**: `2meet-quotation`
|
||||
- **Phase**: 4
|
||||
- **預估行數**: ~56
|
||||
- **Slug 短碼**: `quotation`
|
||||
|
||||
簡述:2meet-quotation 8 張自訂表 (2mq_*) 向 TMDO Custom Table Registry 註冊
|
||||
|
||||
完整拆分計畫見 `~/.claude/plans/wp-data-optimizer-2meet-data-optimizer-zesty-liskov.md`。
|
||||
|
||||
---
|
||||
|
||||
## 邊界
|
||||
|
||||
- ✅ 本 AddOn 觸碰:quotation 相關 schema 註冊(postmeta zone fields / custom tables / entity groups)+ 可選 admin / CLI
|
||||
- ❌ 本 AddOn **不**觸碰:2meet-data-optimizer 核心、其他 AddOn、目標外掛 runtime 邏輯
|
||||
- ❌ 本 AddOn **不**繞過:Hook Bus / TMDO_API(必須走公開合約)
|
||||
|
||||
---
|
||||
|
||||
## 命名前綴
|
||||
|
||||
- 類別:`TMDO_Quotation_*`
|
||||
- 函式:`tmdo_quotation_*`
|
||||
- 常數:`TMDO_QUOTATION_VERSION` / `TMDO_QUOTATION_PATH` / `TMDO_QUOTATION_URL` / `TMDO_QUOTATION_FILE`
|
||||
- Text-domain:`tmdo-quotation`
|
||||
|
||||
---
|
||||
|
||||
## 公開合約消費(從核心)
|
||||
|
||||
```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( 'quotation-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-quotation` 已安裝並啟用
|
||||
|
||||
> 本 AddOn 透過 WordPress `Requires Plugins:` 強制相依,先決條件未滿足時無法啟用。
|
||||
|
||||
---
|
||||
|
||||
## Steps
|
||||
|
||||
```bash
|
||||
# 上傳 + 啟用
|
||||
wp plugin install /path/to/2meet-data-optimizer-quotation-addon-v0.1.0.zip --activate
|
||||
|
||||
# 驗證
|
||||
wp tmdo doctor --provider=quotation-addon
|
||||
wp tmdo custom-tables --provider=quotation-addon
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Rollback
|
||||
|
||||
```bash
|
||||
wp plugin deactivate 2meet-data-optimizer-quotation-addon
|
||||
# 目標外掛 (2meet-quotation) 仍可正常運作,
|
||||
# 讀寫 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 Quotation AddOn
|
||||
|
||||
> 父外掛架構決策見 [`../2meet-data-optimizer/DESIGN.md`](../2meet-data-optimizer/DESIGN.md)
|
||||
|
||||
---
|
||||
|
||||
## 角色定位
|
||||
|
||||
本 AddOn 是 `2meet-data-optimizer` 的整合層,負責將 `2meet-quotation` 的 EAV 模式(postmeta / 自訂表)橋接到核心反 EAV 引擎。
|
||||
|
||||
- **不**修改 `2meet-quotation` 本身
|
||||
- **不**繞過 `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-quotation 本體啟動
|
||||
init:0 核心 fire tmdo_register_* → 本 AddOn 的 callback 執行
|
||||
```
|
||||
|
||||
詳見 plan 文件第 3 章「載入順序」。
|
||||
|
||||
---
|
||||
|
||||
## 為什麼是獨立 AddOn 而非塞進核心
|
||||
|
||||
- 核心 `2meet-data-optimizer` 對外承諾「零依存任何業務外掛」
|
||||
- 整合層發版節奏應跟隨 `2meet-quotation` 而非核心
|
||||
- 站台不用 `2meet-quotation` 時不需被迫載入這段程式碼
|
||||
|
||||
---
|
||||
|
||||
## 邊界檢查清單
|
||||
|
||||
- [ ] 不直接 `SELECT FROM wp_*meta`
|
||||
- [ ] 不繞過 Hook Bus
|
||||
- [ ] 所有 SQL 走 `$wpdb->prepare()`
|
||||
- [ ] DB 表名走 `TMDO_DB::table()`
|
||||
- [ ] 對外只 expose `TMDO_Quotation_*` 命名空間
|
||||
@@ -0,0 +1,43 @@
|
||||
# PLAN — 2meet Data Optimizer Quotation 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` 提煉
|
||||
- **預估行數**: ~56 行
|
||||
- **目標外掛**: `2meet-quotation`
|
||||
|
||||
---
|
||||
|
||||
## 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_Quotation_ 重命名
|
||||
- [ ] 移除對 wp-data-optimizer 內部 class 的依存(改走 TMDO_API 公開合約)
|
||||
- [ ] 完善 bootstrap:實作 init() 載入順序
|
||||
- [ ] 補完 7 件 MD 的細節
|
||||
- [ ] 跑 `scripts/package-plugin.sh 2meet-data-optimizer-quotation-addon` 通過 10 終檢
|
||||
- [ ] dev30 e2e
|
||||
|
||||
---
|
||||
|
||||
## Lessons learned
|
||||
|
||||
- (Phase 4 起記錄)
|
||||
@@ -0,0 +1,51 @@
|
||||
# 2meet Data Optimizer — Quotation AddOn
|
||||
|
||||
> 為 **2meet-quotation** 報價系統提供 8 張自訂表的 schema 健診整合。
|
||||
|
||||
---
|
||||
|
||||
## What it does
|
||||
|
||||
向 `TMDO_Custom_Table_Registry` 註冊 8 張 `wp_2mq_*` 表(其中 3 張關聯到 `hp_vendor` post type):
|
||||
|
||||
| 表名 | post_type_link |
|
||||
|---|---|
|
||||
| `2mq_quotations` | hp_vendor |
|
||||
| `2mq_vendor_presets` | hp_vendor |
|
||||
| `2mq_vendor_catalog_prices` | hp_vendor |
|
||||
| `2mq_quotation_items` | — |
|
||||
| `2mq_quotation_history` | — |
|
||||
| `2mq_catalog_categories` | — |
|
||||
| `2mq_catalog_items` | — |
|
||||
| `2mq_quotation_templates` | — |
|
||||
|
||||
---
|
||||
|
||||
## Requirements
|
||||
|
||||
- WordPress ≥ 6.0
|
||||
- PHP ≥ 8.1
|
||||
- 2meet-data-optimizer ≥ 0.1.0
|
||||
- 2meet-quotation
|
||||
|
||||
---
|
||||
|
||||
## Installation
|
||||
|
||||
```bash
|
||||
wp plugin install /path/to/2meet-data-optimizer-quotation-addon-v0.1.0.zip --activate
|
||||
|
||||
wp tmdo custom-tables --provider=quotation-addon
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 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-quotation-addon",
|
||||
"description": "2meet-quotation 8 張自訂表 (2mq_*) 向 TMDO Custom Table Registry 註冊",
|
||||
"type": "wordpress-plugin",
|
||||
"license": "GPL-2.0-or-later",
|
||||
"keywords": ["wordpress", "2meet-data-optimizer", "addon", "quotation"],
|
||||
"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-quotation-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 Quotation AddOn.
|
||||
*
|
||||
* @package TMDO_QUOTATION
|
||||
* @since 0.1.0
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
final class TMDO_Quotation_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-quotation',
|
||||
false,
|
||||
dirname( plugin_basename( TMDO_QUOTATION_FILE ) ) . '/languages'
|
||||
);
|
||||
|
||||
require_once TMDO_QUOTATION_PATH . 'includes/class-tmdo-quotation.php';
|
||||
|
||||
if ( class_exists( 'TMDO_Quotation' ) && method_exists( 'TMDO_Quotation', 'register' ) ) {
|
||||
TMDO_Quotation::register();
|
||||
}
|
||||
}
|
||||
|
||||
public static function missing_core_notice(): void {
|
||||
echo '<div class="notice notice-error"><p>';
|
||||
echo esc_html__( '2meet Data Optimizer Quotation AddOn 需要 2meet-data-optimizer 核心外掛,請先安裝並啟用。', 'tmdo-quotation' );
|
||||
echo '</p></div>';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
/**
|
||||
* TMDO_Quotation — integration with 2meet-quotation (Wave 2 / v2.1.0).
|
||||
*
|
||||
* 2meet-quotation 採全 flat-custom-table 架構(8 張 wp_2mq_* 表),無 postmeta
|
||||
* 依賴。本整合僅將其表登記到 Custom_Table_Registry,讓 wp wpdo doctor 與
|
||||
* benchmark 涵蓋。
|
||||
*
|
||||
* @package WP_Data_Optimizer
|
||||
* @since 2.0.0
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
// phpcs:disable Squiz.Commenting.FunctionComment.Missing,Squiz.Commenting.InlineComment.InvalidEndChar,Generic.Commenting.DocComment.MissingShort,WordPress.DB.PreparedSQL.InterpolatedNotPrepared,WordPress.PHP.YodaConditions,Generic.CodeAnalysis.EmptyStatement -- v2.0.0 partner integrations: pure registration helpers + intentional silent catches.
|
||||
|
||||
/**
|
||||
* 2meet-quotation 整合。
|
||||
*/
|
||||
final class TMDO_Quotation {
|
||||
|
||||
public static function register(): void {
|
||||
$detected = class_exists( 'TMQUO_Main' )
|
||||
|| class_exists( 'TMQUO_Plugin' )
|
||||
|| file_exists( WP_PLUGIN_DIR . '/2meet-quotation/2meet-quotation.php' );
|
||||
if ( ! $detected ) {
|
||||
return;
|
||||
}
|
||||
add_action( 'wpdo_register_custom_tables', array( __CLASS__, 'register_custom_tables' ) );
|
||||
}
|
||||
|
||||
public static function register_custom_tables( TMDO_Custom_Table_Registry $registry ): void {
|
||||
$tables = array(
|
||||
'2mq_quotations' => array( 'id', 'hp_vendor' ), // vendor_id 關聯 hp_vendor
|
||||
'2mq_quotation_items' => array( 'id', null ),
|
||||
'2mq_quotation_history' => array( 'id', null ),
|
||||
'2mq_vendor_presets' => array( 'id', 'hp_vendor' ),
|
||||
'2mq_catalog_categories' => array( 'id', null ),
|
||||
'2mq_catalog_items' => array( 'id', null ),
|
||||
'2mq_quotation_templates' => array( 'id', null ),
|
||||
'2mq_vendor_catalog_prices' => array( 'id', 'hp_vendor' ),
|
||||
);
|
||||
foreach ( $tables as $table_name => $meta ) {
|
||||
$registry->register(
|
||||
'2meet-quotation',
|
||||
array(
|
||||
'table_name' => $table_name,
|
||||
'primary_key' => $meta[0],
|
||||
'post_type_link' => $meta[1],
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
/**
|
||||
* Uninstall handler for 2meet Data Optimizer Quotation AddOn.
|
||||
*
|
||||
* 僅清理本 AddOn 自有 schema(核心 wp_wpdo_* 系統表保留給 core)。
|
||||
*
|
||||
* @package TMDO_QUOTATION
|
||||
*/
|
||||
|
||||
if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
// Phase 4 完整實作。Phase 0 stub:保留所有資料以避免誤刪。
|
||||
Reference in New Issue
Block a user