Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
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 removed .DS_Store
Binary file not shown.
57 changes: 57 additions & 0 deletions .distignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Files and folders that never ship in the customer zip.
# Read by bin/build-release.sh (rsync --exclude-from). Mirrors gruntfile.js copy:build;
# change both together.

# VCS / CI / editor
/.git
/.github
.gitignore
.gitattributes
.distignore
.editorconfig
.DS_Store
Thumbs.db
/.vscode
/.idea
/.playwright-mcp

# Dependencies and build output
/node_modules
/vendor
/build
/dist
*.zip
*.map
*.log

# Build / lint / test config
/gruntfile.js
/Gruntfile.js
/package.json
/package-lock.json
/composer.json
/composer.lock
/phpcs.xml
/phpcs.xml.dist
/phpstan.neon
/phpstan.neon.dist
/phpunit.xml
.eslintrc*
.stylelintrc*
/.wbcom-i18n.json

# WordPress.org listing assets (uploaded to SVN assets/, never inside the plugin)
/.wordpress-org
/screenshot-*

# Dev-only folders
/tests
/bin
/docs
/marketing
/audit
/plan
/plans

# All markdown (CLAUDE.md, AUDIT-VERDICT.md, BUILD-LOG.md, ...)
*.md
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ node_modules
build/
# Build artifacts (zips are release outputs, not source).
dist/
.DS_Store
5 changes: 3 additions & 2 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@

## Quick reference
- **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`
- **Version**: `1.7.7` (header + `BP_ACTIVITY_LINK_PREVIEW_VERSION` + package.json; readme `Stable tag` moves at release)
- **Dev branch**: `1.7.7`
- **Build / CI**: `bash bin/build-release.sh` (zip in `dist/`, excludes from `.distignore`), `bash bin/local-ci.sh`
- **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`
Expand Down
2 changes: 1 addition & 1 deletion assets/css/bp-activity-link-preview.css
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ so keying the dark scope off data-bx-mode is what actually produces a
dark card - a body.buddyx-dark-theme scope would resolve back to the
light --bx-color-* values and render light. Verified in-browser.

There is intentionally NO @media (prefers-color-scheme: dark) block.
The palette never follows the operating system setting.
Dark is opt-in via the theme's explicit data-bx-mode attribute only; the
plugin never maintains a duplicate OS-driven palette.
--------------------------------------------------------------*/
Expand Down
151 changes: 42 additions & 109 deletions assets/js/bp-activity-link-preview.js

Large diffs are not rendered by default.

25 changes: 16 additions & 9 deletions audit/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -167,67 +167,74 @@
"where": "bp-activity-link-preview.php:119",
"purpose": "Enqueue CSS/JS + dashicons + Twitter + Facebook SDK + localized data (gated by bp_activity_link_preview_should_load_assets)."
},
{
"name": "bp_before_activity_post_form",
"priority": 10,
"callback": "bp_activity_link_preview_enqueue_for_post_form",
"where": "bp-activity-link-preview.php:120",
"purpose": "Enqueue the same assets wherever a BuddyPress activity post form renders (Post From Anywhere shortcode/block/widget); bp_activity_link_preview_load_assets is still honoured with a true default."
},
{
"name": "bp_init",
"priority": 999,
"callback": "bp_activity_link_preview_disable_buddyboss_preview",
"where": "bp-activity-link-preview.php:122",
"where": "bp-activity-link-preview.php:123",
"purpose": "Remove BuddyBoss's own link preview filter to avoid duplicates (remove_filter at :193)."
},
{
"name": "bp_init",
"priority": 10,
"callback": "bp_activity_link_preview_init_comment_filter",
"where": "bp-activity-link-preview.php:134",
"where": "bp-activity-link-preview.php:135",
"purpose": "Register comment-content filter when comment previews enabled."
},
{
"name": "wp_ajax_bp_activity_parse_url_preview",
"priority": 10,
"callback": "bp_activity_parse_url_preview",
"where": "bp-activity-link-preview.php:125",
"where": "bp-activity-link-preview.php:126",
"purpose": "AJAX URL-parse endpoint."
},
{
"name": "bp_activity_after_save",
"priority": 10,
"callback": "bp_activity_link_preview_save_link_data",
"where": "bp-activity-link-preview.php:128",
"where": "bp-activity-link-preview.php:129",
"purpose": "Persist preview data to activity meta on save (handler at :703)."
},
{
"name": "bp_get_activity_content_body",
"priority": 8,
"callback": "bp_activity_link_preview_content_body_with_comments",
"where": "bp-activity-link-preview.php:131",
"where": "bp-activity-link-preview.php:132",
"purpose": "Append rendered preview to activity content body (handler at :868)."
},
{
"name": "bp_activity_comment_content",
"priority": 10,
"callback": "bp_activity_link_preview_comment_content",
"where": "bp-activity-link-preview.php:1094",
"where": "bp-activity-link-preview.php:1132",
"purpose": "Append rendered preview to comment content (conditionally registered inside bp_activity_link_preview_init_comment_filter; handler at :933)."
},
{
"name": "bp_activity_allowed_tags",
"priority": 10,
"callback": "bp_activity_link_preview_allowed_tags",
"where": "bp-activity-link-preview.php:137",
"where": "bp-activity-link-preview.php:138",
"purpose": "Allow div/img/button/span/i/iframe markup in activity content for previews (handler at :1076)."
},
{
"name": "bp_rest_activity_prepare_value",
"priority": 10,
"callback": "bp_activity_link_preview_data_embed_rest_api",
"where": "bp-activity-link-preview.php:140",
"where": "bp-activity-link-preview.php:141",
"purpose": "Embed preview meta into BP REST activity response (handler at :1140)."
},
{
"name": "wp_head",
"priority": 10,
"callback": "bp_activity_link_preview_add_facebook_root_div",
"where": "bp-activity-link-preview.php:143",
"where": "bp-activity-link-preview.php:144",
"purpose": "Output #fb-root div on BP activity/group/user pages for Facebook SDK (handler at :1156)."
}
],
Expand Down
87 changes: 87 additions & 0 deletions bin/build-release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
#!/usr/bin/env bash
# Build the customer zip: dist/buddypress-activity-link-preview-<version>.zip
#
# Usage: bash bin/build-release.sh [--allow-dirty]
#
# --allow-dirty build from an uncommitted tree (local checks only, never a release).
#
# Gates: clean tree, version agreement (header, constant, Stable tag, package.json,
# changelog block), docs lint, zip contents (no dev files, required files present).
# The pre-release browser smoke is run separately with the wp-plugin-smoke skill.
#
# Exit codes: 1 generic, 2 dirty tree, 3 version mismatch, 4 zip leaks dev files, 5 docs lint.
set -euo pipefail

SLUG="buddypress-activity-link-preview" # zip folder name (matches the released zips)
MAIN="bp-activity-link-preview.php"
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
DIST_DIR="${ROOT}/dist"
STAGE_DIR="${DIST_DIR}/${SLUG}"

ALLOW_DIRTY=0
for arg in "$@"; do
case "$arg" in
--allow-dirty) ALLOW_DIRTY=1 ;;
*) echo "Unknown option: $arg" >&2; exit 1 ;;
esac
done

cd "$ROOT"

# --- 1. Clean tree -----------------------------------------------------------
if [ "$ALLOW_DIRTY" -eq 0 ] && [ -n "$(git status --porcelain 2>/dev/null)" ]; then
echo "FAIL: working tree has uncommitted changes. Commit first, or --allow-dirty for a local check." >&2
exit 2
fi

# --- 2. Version agreement ----------------------------------------------------
HEADER_VERSION="$(grep -m1 -E '^[[:space:]*]*Version:' "$MAIN" | awk -F': *' '{print $2}' | tr -d ' \r\n')"
CONST_VERSION="$(grep -m1 "define( 'BP_ACTIVITY_LINK_PREVIEW_VERSION'" "$MAIN" | grep -oE "[0-9]+\.[0-9]+\.[0-9]+" || true)"
STABLE_TAG="$(grep -m1 -E '^Stable tag:' readme.txt | awk -F': *' '{print $2}' | tr -d ' \r\n')"
PKG_VERSION="$(grep -m1 '"version"' package.json | grep -oE '[0-9]+\.[0-9]+\.[0-9]+' || true)"
VERSION="$HEADER_VERSION"

echo "==> ${SLUG} ${VERSION}"
echo " header=${HEADER_VERSION} constant=${CONST_VERSION} stable_tag=${STABLE_TAG} package.json=${PKG_VERSION}"
if [ -z "$VERSION" ] || [ "$VERSION" != "$CONST_VERSION" ] || [ "$VERSION" != "$STABLE_TAG" ] || [ "$VERSION" != "$PKG_VERSION" ]; then
echo "FAIL: version mismatch - plugin header, BP_ACTIVITY_LINK_PREVIEW_VERSION, readme Stable tag and package.json must agree." >&2
exit 3
fi
if ! grep -qE "^= ${VERSION//./\\.} " readme.txt; then
echo "FAIL: readme.txt has no changelog block '= ${VERSION} ...='." >&2
exit 3
fi

# --- 3. Docs lint ------------------------------------------------------------
DOCS_LINT="${HOME}/.claude/skills/wbcom-documentation/bin/lint-plugin-docs.mjs"
if [ -f "$DOCS_LINT" ]; then
echo "==> Docs lint"
node "$DOCS_LINT" . || { echo "FAIL: docs lint reported errors." >&2; exit 5; }
else
echo "WARN: docs lint not found at ${DOCS_LINT}; skipped."
fi

# --- 4. Stage + zip ------------------------------------------------------------
ZIP_PATH="${DIST_DIR}/${SLUG}-${VERSION}.zip"
rm -rf "$STAGE_DIR" "$ZIP_PATH"
mkdir -p "$STAGE_DIR"
rsync -a --exclude-from="${ROOT}/.distignore" ./ "${STAGE_DIR}/"
( cd "$DIST_DIR" && zip -rqX "$ZIP_PATH" "${SLUG}/" )
rm -rf "$STAGE_DIR"

# --- 5. Verify the zip -----------------------------------------------------------
# Listing captured once: piping unzip into `grep -q` under pipefail fails on SIGPIPE.
LISTING="$(unzip -Z1 "$ZIP_PATH")"
LEAKS="$(printf '%s\n' "$LISTING" | grep -iE "^${SLUG}/(docs|marketing|audit|tests|bin|node_modules|plan|plans|\.wordpress-org)/|\.md$|\.map$|(^|/)(package(-lock)?\.json|composer\.(json|lock)|gruntfile\.js|phpstan[^/]*|\.?phpcs\.xml(\.dist)?|\.distignore|\.git[^/]*|\.DS_Store|\.wbcom-i18n\.json|screenshot-[^/]*)$" || true)"
if [ -n "$LEAKS" ]; then
echo "FAIL: customer zip contains dev files:" >&2
echo "$LEAKS" >&2
exit 4
fi
for required in "$MAIN" readme.txt "languages/${SLUG}.pot" assets/js/bp-activity-link-preview.js assets/css/bp-activity-link-preview.css; do
printf '%s\n' "$LISTING" | grep -qx "${SLUG}/${required}" || { echo "FAIL: zip is missing ${required}" >&2; exit 4; }
done

COUNT="$(printf '%s\n' "$LISTING" | grep -vc '/$')"
SIZE_KB="$(( $(stat -f%z "$ZIP_PATH" 2>/dev/null || stat -c%s "$ZIP_PATH") / 1024 ))"
echo "OK: ${ZIP_PATH#"$ROOT"/} - ${COUNT} files, ${SIZE_KB} KB, no dev files"
60 changes: 60 additions & 0 deletions bin/local-ci.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#!/usr/bin/env bash
# Local CI for BuddyPress Activity Link Preview. Exits non-zero if any stage fails.
#
# Usage: bash bin/local-ci.sh
#
# Stages:
# 1 php -l over every plugin PHP file
# 2 WPCS (phpcs --standard=WordPress, errors only)
# 3 node --check on the frontend script
# 4 docs lint (wbcom-documentation)
# 5 core-first check (CF1-CF7)
# 6 portfolio gate-check (E6 "already tagged" is tolerated between releases)
set -uo pipefail

ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
SKILLS="${HOME}/.claude/skills"
cd "$ROOT" || exit 1
FAILED=()
stage() { echo; echo "==> $1"; }
fail() { FAILED+=("$1"); echo "FAIL: $1"; }

PHP_FILES=()
while IFS= read -r -d '' f; do PHP_FILES+=("$f"); done < <(find . -name '*.php' -not -path './node_modules/*' -not -path './dist/*' -not -path './build/*' -not -path './vendor/*' -print0)

stage "1. php -l"
LINT_ERR=0
for f in "${PHP_FILES[@]}"; do
out="$(php -l "$f" 2>&1)" || { echo "$out"; LINT_ERR=1; }
done
[ "$LINT_ERR" -eq 0 ] && echo " ${#PHP_FILES[@]} file(s) parse" || fail "php -l"

stage "2. WPCS (errors only)"
if command -v phpcs >/dev/null 2>&1; then
phpcs -q -n --standard=WordPress --report=emacs "${PHP_FILES[@]}" && echo " no errors" || fail "phpcs"
else
fail "phpcs not installed (composer global require wp-coding-standards/wpcs)"
fi

stage "3. JavaScript syntax"
node --check assets/js/bp-activity-link-preview.js && echo " parses" || fail "node --check"

stage "4. Docs lint"
node "${SKILLS}/wbcom-documentation/bin/lint-plugin-docs.mjs" . || fail "docs lint"

stage "5. core-first"
php "${SKILLS}/wp-plugin-development/scripts/core-first-check.php" . || fail "core-first"

stage "6. gate-check"
GATE_OUT="$(bash "${SKILLS}/wp-plugin-development/scripts/gate-check.sh" . 2>&1)"
echo "$GATE_OUT"
GATE_FAILS="$(printf '%s\n' "$GATE_OUT" | sed $'s/\x1b\\[[0-9;]*m//g' | grep -E '^[[:space:]]*FAIL[[:space:]]' | grep -vE '^[[:space:]]*FAIL[[:space:]]+E6[[:space:]]' || true)"
[ -z "$GATE_FAILS" ] || fail "gate-check: $(printf '%s' "$GATE_FAILS" | tr -s ' ' | tr '\n' ';')"

echo
if [ "${#FAILED[@]}" -gt 0 ]; then
echo "LOCAL CI FAILED (${#FAILED[@]}):"
printf ' - %s\n' "${FAILED[@]}"
exit 1
fi
echo "LOCAL CI PASSED"
Loading
Loading