BP_Activity_oEmbed_Extension::use_custom_iframe_sandbox_attribute( string $result, object $data, string $url )
Use our custom <iframe>
sandbox attribute in our oEmbed response.
Description
WordPress sets the
See also
- BP_Activity_Component::modify_iframe(): where our custom sandbox value is set.
Parameters
- $result
-
(Required) The oEmbed HTML result.
- $data
-
(Required) A data object result from an oEmbed provider.
- $url
-
(Required) The URL of the content to be embedded.
Return
(string)
Source
File: bp-activity/classes/class-bp-activity-oembed-extension.php
public function use_custom_iframe_sandbox_attribute( $result, $data, $url ) { // Make sure we are on a BuddyBoss activity oEmbed request. if ( false === isset( $data->x_buddypress ) || 'activity' !== $data->x_buddypress ) { return $result; } // Get unfiltered sandbox attribute from our own oEmbed response. $sandbox_pos = strpos( $data->html, 'sandbox=' ) + 9; $sandbox = substr( $data->html, $sandbox_pos, strpos( $data->html, '"', $sandbox_pos ) - $sandbox_pos ); // Replace only if our sandbox attribute contains 'allow-top-navigation'. if ( false !== strpos( $sandbox, 'allow-top-navigation' ) ) { $result = str_replace( ' sandbox="allow-scripts"', " sandbox=\"{$sandbox}\"", $result ); // Also remove 'security' attribute; this is only used for IE < 10. $result = str_replace( 'security="restricted"', "", $result ); } return $result; }
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.