# 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`

---

Contact: dev@trok.co.jp
