Repository navigation
fix(godam): protect activity player markup from content filters - #2387
Conversation
The GoDAM player was expanded inline into BuddyPress activity content and then run through make_clickable, the theme hashtag linkifier and wpautop. Those filters turned the #hex colours and URLs inside the player's data-* attributes into <a> tags, shattering the markup so Video.js got no source and the video could not play. Emit a neutral placeholder during normal filtering and swap in the real [godam_video] output on a PHP_INT_MAX pass, after every other bp_get_activity_content_body filter has run. Covers the activity-video and activity-comment paths; surrounding activity text keeps its formatting. Closes #2386 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Intenzi
left a comment
There was a problem hiding this comment.
The late-expansion placeholder pattern cleanly protects the main activity video from #hex and URL linkifier corruption (tested and verified with custom hashtag linkifiers).
However, comment video attachments render as empty, unexpanded placeholder <div> tags because comments follow the bp_activity_comment_content pipeline rather than bp_get_activity_content_body.
See the inline suggestion to add the missing filter hook 🙇
Activity comments render via bp_get_activity_content + bp_activity_comment_content and never hit bp_get_activity_content_body, so comment-video placeholders were left in the DOM as empty <div>s. Also register the expansion on bp_activity_comment_content (PHP_INT_MAX) so comment videos expand too. Addresses review feedback on #2387. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
Unable to PHPCS or SVG scan one or more files due to error running PHPCS/SVG scanner:
The error may be temporary. If the error persists, please contact a human (commit-ID: c6bb314). |
|
Good catch, thanks @Intenzi — confirmed. Comments render via bp_get_activity_content + bp_activity_comment_content and never hit bp_get_activity_content_body, so the comment-video placeholders were left as empty s. Added the expansion on bp_activity_comment_content at PHP_INT_MAX too (c6bb314), and verified on a real BuddyPress runtime that a comment placeholder now expands to the player. Both activity and comment paths are covered.
|
What
When a GoDAM video is shown inside a BuddyPress activity item, the player markup was corrupted by the activity content filters, leaving the
<video>with no source so playback never started. This PR makes the player injection immune to those filters.Closes #2386.
Why it broke
templates/media/godam-integration.phpexpanded the player inline viado_shortcode()inside abp_get_activity_content_bodyfilter at priority 10, returning the full player HTML as part of the activity content. BuddyPress (and the theme) then run their formatting filters on that same content:make_clickable@9,wptexturize/wpautop/force_balance_tags/ nofollow @10 (BuddyPress core)#hashtag → ?activity_search=linkifier on topThose filters found the
#hexcolour values (e.g.appearanceColor":"#fff") and URLs inside the player'sdata-controls/data-optionsattributes and wrapped each in an<a href="…">. Injecting an<atag inside<div data-controls="…">shatters the tag; the browser mis-parses the rest, Video.js can't readsources, and the<video>ends up with zero<source>children.This surfaces most once a video has a layer (e.g. a CTA layer), because the layer causes the saved config to carry the control-bar appearance colours that the linkifiers latch onto.
The fix
Priority-agnostic late expansion:
#and no URL —<div class="godam-activity-player-placeholder" data-media-id="…" data-player-id="…" data-context="…"></div>. A<div>is left alone bywpautop, and there is nothing formake_clickable/ the hashtag filter to linkify.bp_get_activity_content_bodyfilter atPHP_INT_MAXreplaces each placeholder with the realdo_shortcode('[godam_video …]')output — running after every other content filter, so the player markup is never exposed to them.Applied to both the activity-video and activity-comment paths. Surrounding activity text keeps its normal hashtag/URL formatting.
Behaviour / safety
[godam_video]shortcode args, just injected later.strposguard when no placeholder is present, so it is a no-op for all non-GoDAM activity and every otherbp_get_activity_content_bodycall.RTMEDIA_GODAM_ACTIVE; the template isrequire_once'd, so no redeclaration risk.Testing
appearanceColor":"<a href="https…) and verified the placeholder survives the filter chain while the player renders clean with a<source>, and surrounding hashtags/URLs still linkify.Acceptance criteria
<div>renders with intactdata-controls(no injected<a>, no?activity_search/ debris attributes, no<p>wrap).<video>has its<source>children; the video plays and the CTA layer appears.🤖 Generated with Claude Code
Verification evidence
Verified end-to-end on a real WordPress + BuddyPress + rtMedia + GoDAM stack, using a real GoDAM video with 7 layers and a
#hexbrand colour (#0095ff):#hexcolours leak as text and get linkified — and the player has no playable source (the reported "video not playable").An automated pass through the real
bp_get_activity_content_bodyfilter chain reproduces the exact corruption signature (appearanceColor":"<a href=) on the old inline path and confirms the player stays intact on the fixed path.