# Internal Developer Notes - Affiliate Quick Link Shortcode for DMM

## Plugin Structure

- Single shortcode handler: `quick_link_dmm`
- Uses `wp_remote_get()` to fetch DMM Affiliate API response
- Accepts either `cid` or `aid` for content lookup
- Supports optional `link_only` and `size` parameters

## Key Constants

- API request uses `affiliate_id = lab888-990`
- Display links use default `affiliate_id = lab888-001` (overridable via `aff` param)
- API ID is retrieved using `get_option('quick_link_dmm_api_id')` from plugin settings

## Security

- All shortcode attributes are sanitized via `sanitize_text_field()`
- API results decoded with `json_decode()`
- Output uses proper escaping: `esc_attr()`, `esc_url()`, `esc_html()`

## Special Behaviors

- `link_only="1"`: Outputs plain URL
- `link_only="wp"`: Outputs URL with `!` prefix to suppress oEmbed
- `size="video"`: Outputs iframe-based sample video
- `cid` takes priority if both `cid` and `aid` are specified

## Optimization Targets

- Implement response caching using transients
- Add fallback alt text if API fails
- Graceful degradation on API failure: HTML comment returned

## File Naming Conventions

- Main file: `affiliate-quick-link-dmm.php`
- Slug: `affiliate_quick_link_dmm`
- Shortcode tag: `[quick_link_dmm]`

## Release Workflow

1. Validate functional changes and test shortcode outputs
2. Update `readme.txt`, `README-ja.txt`, and `changelog.md`
3. Tag release as `v1.3.x` in Git
4. Deploy to `trok.co.jp/plugins/` or generate downloadable `.zip`

## v1.4.1 フローティングバナー新仕様

- 表示制御は外部 JS（floating-banner.js）に一本化
- バナー要素は body 直下に JS で append し、重なりコンテキスト問題を根本解決
- z-index は PHP/JS 両方で調整可能（サイドメニューの上・モーダルの下など柔軟に対応）
- show_at/delay パラメータをショートコードで受け取り、data 属性で JS に渡す
- show_at=0 で delay のみ有効、0 以外は従来通りスクロール判定
- 初期状態は opacity:0; pointer-events:none;、JS で条件を満たしたときのみ表示
- 古いインライン JS や opacity 上書き処理は完全削除

---

Contact: dev@trok.co.jp
