BP_Core_oEmbed_Extension::filter_embed_html( string $retval )
Filters the embed HTML for our BP oEmbed endpoint.
Description
Parameters
- $retval
-
(Required) Current embed HTML.
Return
(string)
Source
File: bp-core/classes/class-bp-core-oembed-extension.php
public function filter_embed_html( $retval ) {
if ( false === isset( buddypress()->{$this->slug_endpoint}->embedurl_in_progress ) && ! $this->is_page() ) {
return $retval;
}
$url = $this->set_permalink();
$item_id = $this->is_page() ? $this->validate_url_to_item_id( $url ) : buddypress()->{$this->slug_endpoint}->embedid_in_progress;
// Change 'Embedded WordPress Post' to custom title.
$custom_title = $this->set_iframe_title( $item_id );
if ( ! empty( $custom_title ) ) {
$title_pos = strpos( $retval, 'title=' ) + 7;
$title_end_pos = strpos( $retval, '"', $title_pos );
$retval = substr_replace( $retval, esc_attr( $custom_title ), $title_pos, $title_end_pos - $title_pos );
}
// Add 'max-width' CSS attribute to IFRAME.
// This will make our oEmbeds responsive.
if ( false === strpos( $retval, 'style="max-width' ) ) {
$retval = str_replace( '<iframe', '<iframe style="max-width:100%"', $retval );
}
// Remove default <blockquote>.
$retval = substr( $retval, strpos( $retval, '</blockquote>' ) + 13 );
// Set up new fallback HTML
// @todo Maybe use KSES?
$fallback_html = $this->set_fallback_html( $item_id );
/**
* Dynamic filter to return BP oEmbed HTML.
*
* @since BuddyPress 2.6.0
*
* @var string $retval
*/
return apply_filters( "bp_{$this->slug_endpoint}_embed_html", $fallback_html . $retval );
}
Changelog
| Version | Description |
|---|---|
| BuddyPress 2.6.0 | Introduced. |
Questions?
We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.