[buddypress-trac] [BuddyPress Trac] #6772: BuddyPress Embeds for activity, user profiles, groups
noreply at wordpress.org
Tue Dec 15 21:07:39 UTC 2015
#6772: BuddyPress Embeds for activity, user profiles, groups
Reporter: imath | Owner:
Type: idea | Status: new
Priority: normal | Milestone: 2.5
Component: API | Version:
Severity: normal | Resolution:
Keywords: dev-feedback has-patch |
Changes (by r-a-y):
* keywords: dev-feedback => dev-feedback has-patch
Attached is a first pass at activity oEmbeds.
Some dev notes:
1. Activity oEmbed links
- The activity oEmbed link is the members activity permalink -
`example.com/members/USER/activity/XXX/` not `example.com/activity/p/XXX`
- Pasting this link in the WP TinyMCE editor works (see screenshot)
to hide the fallback `<blockquote>` does not fire. I also had to register
the activity link as an oEmbed provider for this to work in BuddyPress.
See `bp_activity_embed_add_oembed_provider()`. WP's TinyMCE appears to
work without registering an oEmbed provider. Not sure how this works at
the moment, but that is probably the reason why WP posts do not show up as
oEmbed items in BuddyPress.
- You can view what the oEmbed looks like by appending `?embed=true` to it
2. Embed templates
- The default WP embed template - `/wp-includes/embed-template.php` - is a
template that contains all the markup for embedding.
- For BP, I've customized this default template to `/embeds/template.php`.
- I've also split up this template into multiple template parts -
`/embeds/header.php`, `/embeds/footer.php`, etc. - for better
- The BP activity component injects content into this template via the
existing `'embed_content'` hook and a custom template part -
`'/embeds/activity.php`. This works similar to how BP plugins use the
- I've also added a simplistic template hierarchy - `/embeds/template-
single-activity.php`, `/embeds/template.php`. Theme devs can override
these by copying and pasting into their theme directory. (eg.
- I'm using the `/embeds/css.php` file to add inline CSS temporarily.
This should probably be moved to the `'embed_head'` hook, so disregard
this for the time being.
3. Hooking into oEmbed for BuddyPress purposes
- Requires some hackery. WordPress expects a WordPress post ID when
formulating the oEmbed response. To overcome this, I'm passing our
Members Directory page ID and adding some markers so BP can render the
oEmbed response. See `bp_activity_embed_filter_oembed_request_post_id()`
for what I'm doing.
- The `bp_activity_embed_filter_html()` function alters the fallback
`<blockquote>` HTML for BuddyPress purposes.
- The `bp_activity_embed_filter_oembed_response_data()` function filters
the oEmbed JSON response.
Ticket URL: <https://buddypress.trac.wordpress.org/ticket/6772#comment:5>
BuddyPress Trac <http://buddypress.org/>
More information about the buddypress-trac