Skip to content

Fix embeds in BuddyPress activity comments not replaced - #287

Open
bfs2021 wants to merge 1 commit into
epiphyt:mainfrom
bfs2021:fix/buddypress-activity-comment-embed
Open

bfs2021 wants to merge 1 commit into
epiphyt:mainfrom
bfs2021:fix/buddypress-activity-comment-embed

Conversation

@bfs2021

@bfs2021 bfs2021 commented Nov 24, 2026

Copy link
Copy Markdown

Problem

Embeds in BuddyPress activity comments (replies) load directly as iframes without an Embed Privacy consent overlay, while embeds in regular activity updates get the overlay. Fixes #285.

Root cause

BuddyPress does not use the WordPress embed_oembed_html filter for oEmbeds in activity comments — it uses its own bp_embed_oembed_html filter. Embed Privacy only hooks embed_oembed_html (via Post::init()), so the replacement never ran for comment embeds. The existing BuddyPress integration (Buddypress::init()) only hooked bp_get_activity_content_body, which covers activity-update text but not the comment oEmbed path.

Fix

Forward the BuddyPress filter to the WordPress one in Buddypress::init(): register bp_embed_oembed_html → Buddypress::replace_activity_comment_oembed(), which calls apply_filters( 'embed_oembed_html', $html, $url, $attributes ). This reuses the existing Replacer::replace_oembed() hook, so comment embeds get the same consent overlay as every other oEmbed. The callback accepts 3 args to match the forwarded WordPress filter signature.

Note: the separate MutationObserver limitation for AJAX-loaded activity streams (#284) is not addressed here; this change makes the overlay appear — clicking it inside dynamically loaded comments still depends on #284.

Testing

  • Added testReplaceActivityCommentOembedForwardsToWordPressFilter (red before fix: hook missing and method undefined) and extended testInitRegistersHooks to assert the new filter.
  • Full suite: phpunit --no-coverage → 513 tests / 1416 assertions passing (16 pre-existing deprecations).
  • phpcs clean on both changed files (EpiphytCodingStandard).

BuddyPress uses its own bp_embed_oembed_html filter for oEmbeds in activity comments, not WordPress' embed_oembed_html. As a result comment embeds were loaded directly as iframes without an Embed Privacy consent overlay, while regular activity updates were handled. Forward bp_embed_oembed_html to embed_oembed_html so the existing oEmbed replacement applies to comments too. Fixes epiphyt#285
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Embeds in BuddyPress activity comments are not replaced (bp_embed_oembed_html not handled)

1 participant