Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .wordpress-org/banner-1544x500.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .wordpress-org/banner-772x250.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .wordpress-org/icon-128x128.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .wordpress-org/icon-256x256.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
51 changes: 21 additions & 30 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
# Plugin: Activity Link Preview For BuddyPress

> **READ FIRST:** [`audit/manifest.json`](audit/manifest.json) is the canonical inventory — 1 AJAX action, 1 REST-embed filter, 6 own filters, 13 hook listeners, 2 activity-meta keys, **0** admin pages / settings / tables / CPTs / cron / WP-CLI / blocks / shortcodes. Use it before grepping. See also [`audit/FEATURE_AUDIT.md`](audit/FEATURE_AUDIT.md), [`audit/CODE_FLOWS.md`](audit/CODE_FLOWS.md), and the wppqa baseline [`audit/wppqa-baseline-2026-06-05/SUMMARY.md`](audit/wppqa-baseline-2026-06-05/SUMMARY.md). Refresh via `/wp-plugin-onboard --refresh` after non-trivial changes.
> **READ FIRST:** [`audit/manifest.json`](audit/manifest.json) is the canonical inventory — 1 AJAX action, 1 REST-embed filter, 6 own filters, 14 hook listeners, 2 activity-meta keys, **0** admin pages / settings / tables / CPTs / cron / WP-CLI / blocks / shortcodes. Use it before grepping. See also [`audit/FEATURE_AUDIT.md`](audit/FEATURE_AUDIT.md), [`audit/CODE_FLOWS.md`](audit/CODE_FLOWS.md), and the wppqa baseline [`audit/wppqa-baseline-2026-06-05/SUMMARY.md`](audit/wppqa-baseline-2026-06-05/SUMMARY.md). Refresh via `/wp-plugin-onboard --refresh` after non-trivial changes.

> **Development conventions:** Follow the [`wp-plugin-development`](https://example/skills/wp-plugin-development) skill for ALL changes — the 16 critical admin rules, Part 6 Admin UI patterns, design tokens (3-layer model), escaping/security rules, and dev hygiene (no em-dash in i18n, Lucide icons over inline SVG, WPCS). This plugin currently has **no admin UI** (see Admin-UI wrapper below); if one is ever added, it MUST use the NEW card-based shell pattern from `wp-plugin-development` Part 6 — not the legacy `admin/wbcom/` wrapper.

## Quick reference
- **Main file**: `bp-activity-link-preview.php` (single-file, procedural; 1033 lines, 20 functions)
- **Version**: `1.7.5` (header + `BP_ACTIVITY_LINK_PREVIEW_VERSION` + readme `Stable tag` + package.json)
- **Dev branch**: `v1.7.5`
- **Main file**: `bp-activity-link-preview.php` (single-file, procedural; 1280 lines, 23 functions)
- **Version**: `1.7.6` (header + `BP_ACTIVITY_LINK_PREVIEW_VERSION` + readme `Stable tag` + package.json)
- **Dev branch**: `v1.7.6`
- **Customer docs**: `docs/website/` (migrated 2026-08-14; the filters page is the config reference)
- **Namespace**: none (no classes)
- **Text domain**: `buddypress-activity-link-preview`
- **Extends**: none (standalone free plugin)
- **Requires**: BuddyPress **or** BuddyBoss Platform (auto-deactivates on `admin_init` if neither active)

## Architecture
Single procedural file. There is no class layer, container, or seven-layer structure. Bootstrap is `bp_activity_link_preview_bootstrap()` fired from `plugins_loaded@20` (after BuddyPress, which uses default 10) only when the dependency is present. All behavior is hook-driven; extension is via 5 documented filters (see `audit/FEATURE_AUDIT.md`).
Single procedural file. There is no class layer, container, or seven-layer structure. Bootstrap is `bp_activity_link_preview_bootstrap()` fired from `plugins_loaded@20` (after BuddyPress, which uses default 10) only when the dependency is present. All behavior is hook-driven; extension is via 6 documented filters (see `audit/FEATURE_AUDIT.md`).

## Admin-UI wrapper classification: **NONE**
This plugin has **no settings page and no admin UI of any kind.**
Expand All @@ -23,22 +24,24 @@ This plugin has **no settings page and no admin UI of any kind.**
- No `includes/admin/views/shell.php` (NEW shell) — absent.
- No `add_menu_page` / `add_submenu_page` / `add_options_page` / `register_setting` anywhere.
- No `get_option` / `update_option` — zero settings options read or written.
- Only admin-side output: a dependency-missing `admin_notices` error (`bp_activity_link_preview_admin_notice`, registered at `:72` / `:119`).
- Only admin-side output: a dependency-missing `admin_notices` error (`bp_activity_link_preview_admin_notice`, registered at `:106` / `:153`).

Behavior toggles are code-level filters only (notably `bp_activity_link_preview_enable_comments`, default `true`). If a settings UI is added later, classify it NEW and follow `wp-plugin-development` Part 6.

## Key entry points
- AJAX: `bp_activity_parse_url_preview()` (`:170`) — URL parse endpoint (`is_user_logged_in()` + nonce + SSRF guard)
- Parse engine: `bp_activity_link_parse_url()` (`:231`); internal-URL fast path `bp_activity_link_parse_internal_url()` (`:472`)
- Save: `bp_activity_link_preview_save_link_data()` (`:601`) on `bp_activity_after_save`
- Render: `bp_activity_link_preview_render_preview()` (`:885`); content filters at `:744` / `:809`
- REST embed: `bp_activity_link_preview_data_embed_rest_api()` (`:987`) on `bp_rest_activity_prepare_value`
(line numbers verified against 1.7.6)
- AJAX: `bp_activity_parse_url_preview()` (`:245`) — URL parse endpoint (`is_user_logged_in()` + nonce + SSRF guard)
- Parse engine: `bp_activity_link_parse_url()` (`:343`); internal-URL fast path `bp_activity_link_parse_internal_url()` (`:665`)
- Save: `bp_activity_link_preview_save_link_data()` (`:797`) on `bp_activity_after_save`
- Render: `bp_activity_link_preview_render_preview()` (`:1106`)
- REST embed: `bp_activity_link_preview_data_embed_rest_api()` (`:1235`) on `bp_rest_activity_prepare_value`
- Frontend JS: `assets/js/bp-activity-link-preview.js`
- `initSocialEmbeds()` fills the empty `<div data-url>` containers PHP renders for Twitter/X and Facebook. **Called on `$(document).ready()`, on `twttr.ready()`, and from `ajaxComplete`.** Before 1.7.6 it ran only from `ajaxComplete`, so embeds were blank on every server-rendered view.

## Important patterns
- **Multi-platform compat is load-bearing.** Stands down for BuddyBoss native preview and Youzify wall preview to avoid duplicate cards; removes BuddyBoss's own filter at `bp_init@999`. Touching the render/save paths requires re-checking all three integration branches.
- **SSRF guard** on the AJAX endpoint (`:196-204`) blocks localhost/RFC1918/reserved IPs — do not weaken when editing the fetch path.
- **Caching**: per-URL transient `bp_oembed_<md5(url)>`, TTL `DAY_IN_SECONDS`.
- **SSRF guard** `bp_activity_link_preview_is_blocked_host()` (`:305`), applied to the AJAX input URL (`:271`) and the short-URL redirect target (`:389`), blocks localhost/RFC1918/reserved IPs — do not weaken when editing the fetch path.
- **Caching**: per-URL transient `bp_oembed_<md5(url)>`, TTL `DAY_IN_SECONDS`; failed fetches are negative-cached for `bp_activity_link_preview_negative_cache_ttl` (default 15 min).
- **Saved previews render server-side** (PHP filter), so they display with JS off; only compose-time live detection is JS-only.
- **Reddit URLs are deliberately skipped** in save paths.

Expand All @@ -48,20 +51,8 @@ Behavior toggles are code-level filters only (notably `bp_activity_link_preview_
## Onboarding scope note
This onboarding pass was **artefacts-only** (manifest + audit reports + graph + CLAUDE.md + wppqa baseline). The Phase 4.5/4.7/4.8 scaffolds (paired-plugin contract, local-CI pipeline, journeys, scale benchmark, cleanup framework) were intentionally NOT created — no functional code, no CI scaffolding, no commit. Run those companion phases separately if/when desired.

## Recent changes
| Date | Type | Description | Files |
|---|---|---|---|
| 2026-07-29 | release | Bumped 1.7.4 -> 1.7.5 as a corrective release: the 1.7.4 package published to the wp.org slug `activity-link-preview-for-buddypress` contained BuddyPress Post from Anywhere files (trunk + tags/1.7.4). No functional code change. Also corrected two stale "Requires at least 5.9" claims (readme upgrade notice, manifest) - the header has said 6.5 since 1.7.4. | `bp-activity-link-preview.php`, `readme.txt`, `package.json`, `audit/manifest.json`, `CLAUDE.md` |
| 2026-07-10 | a11y+rtl | Added aria-label (Previous/Next image) + aria-hidden icons to the icon-only composer nav buttons; upgraded comment close-button focus from `:focus`+`#0073aa` to token-driven `:focus-visible`; converted physical margins/insets to logical props (margin-inline/inset-inline) with a `[dir=rtl]` float flip for RTL. Browser-verified live preview + dark flip (data-bx-mode). NOTE: investigated adding `body.buddyx-dark-theme`/`body.dark` dark scopes but reverted - dark values defer to `--bx-color-*` which BuddyX/Reign only flip under `[data-bx-mode=dark]`, so a body-class scope renders LIGHT (verified). data-bx-mode-only scoping is correct. | `assets/css/*.css`, `assets/js/*.js` |
| 2026-07-09 | security | DOM-XSS fix: escape scraped title/description/image/url at every JS injection site (both render fns + FB data-href) via the existing escapeHtml(); trusted WP-oEmbed rendered raw. Live-verified payload neutralized. | `assets/js/bp-activity-link-preview.js` |
| 2026-07-09 | bug-fix | YouTube/oEmbed videos now persist to the saved feed: JS sends wp_embed flag, save regenerates embed via wp_oembed_get() + stores wp_embed/embed_html, render outputs it, iframe added to bp_activity_allowed_tags. Was saving as a bare URL. | `bp-activity-link-preview.php`, `assets/js/bp-activity-link-preview.js` |
| 2026-07-09 | a11y | img alt on composer + server-render previews; replaced `outline:0` focus suppression with token-driven `:focus-visible` ring | `bp-activity-link-preview.php`, `assets/js/*.js`, `assets/css/*.css` |
| 2026-07-09 | chore | Removed 4 orphaned wp_localize_script keys + dead Youzify vars; WPCS clean; readme Tested-up-to 7.0; readme platform claims corrected (dropped Reddit/LinkedIn/Instagram); Gruntfile excludes .github/ + audit/ from dist zip | `bp-activity-link-preview.php`, `readme.txt`, `Gruntfile.js`, `assets/css/*.css` |
| 2026-07-03 | security | Sanitize scraped title/description in both comment auto-extraction fallbacks; remove double html_entity_decode on og:description; esc_html description in shared renderer | `bp-activity-link-preview.php` |
| 2026-07-03 | perf | Assets (own CSS/JS + Twitter/FB SDKs + dashicons) load only in activity contexts via bp_activity_link_preview_should_load_assets(); new bp_activity_link_preview_load_assets filter | `bp-activity-link-preview.php` |
| 2026-07-03 | perf | bp_activity_link_parse_url gains negative caching (15-min bpalp_failed sentinel) and $cached_only mode; comment render fallback is cached-only (no live external fetch during render) | `bp-activity-link-preview.php` |
| 2026-07-03 | bug-fix | AJAX response.error now surfaced via showPreviewError() role=alert notice; dashicons enqueued; dead .loading CSS removed; version strings bumped to 1.7.4 | `assets/js/bp-activity-link-preview.js`, `assets/css/bp-activity-link-preview.css`, `package.json`, `audit/manifest.json`, `readme.txt` |
| 2026-07-03 | bug-fix | URL detection no longer extends into following text (contenteditable: getInputValue returns .html(), getURL anchor-first + boundary-normalized fallback) | `assets/js/bp-activity-link-preview.js` |
| 2026-07-03 | bug-fix | Live preview auto-removed when URL deleted from input (new removeLinkPreview counterpart in scrap_URL) | `assets/js/bp-activity-link-preview.js` |
| 2026-07-03 | bug-fix | Dark mode contrast: --bpalp-* tokens consuming BuddyX --bx-color-* with light fallbacks; data-bx-mode dark/auto overrides; token-driven prev/next button hover | `assets/css/bp-activity-link-preview.css` |
| 2026-06-05 | onboard | Generated audit/ manifest + reports + graph + wppqa baseline; wrote READ-FIRST CLAUDE.md | `audit/*`, `CLAUDE.md` |
## Change history

Not tracked here. `readme.txt` owns the customer-facing changelog; Basecamp project 37595370 owns bugs and their status. A Recent-changes table in this file goes stale and actively misleads mid-task, so it was removed on 2026-08-14.

For the current state of the code, read `audit/manifest.json` (canonical inventory) and the entry points above.
1 change: 0 additions & 1 deletion WRAPPER-AUDIT.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
**Branch:** v1.7.4
**Audit date:** 2026-06-05
**Wrapper type:** NONE (intentionally not migrated — single-file procedural, no settings page)
**Auditor:** AutoVAP READ-ONLY pass

---

Expand Down
Loading
Loading