setup_properties(); // Some rudimentary logic checking. if ( empty( $this->slug_endpoint ) ) { return; } $this->setup_hooks(); $this->custom_hooks(); } /** REQUIRED METHODS ****************************************************/ /** * Add content for your oEmbed response here. * * @since 2.6.0 * * @return null */ abstract protected function content(); /** * Add a check for when you are on the page you want to oEmbed. * * You'll want to return a boolean here. eg. bp_is_single_activity(). * * @since 2.6.0 * * @return bool */ abstract protected function is_page(); /** * Validate the URL to see if it matches your item ID. * * @since 2.6.0 * * @param string $url URL to validate. * @return int Your item ID */ abstract protected function validate_url_to_item_id( $url ); /** * Set the oEmbed response data. * * @since 2.6.0 * * @param int $item_id Your item ID to do checks against. * @return array Should contain 'content', 'title', 'author_url', 'author_name' as array * keys. 'author_url' and 'author_name' is optional; the rest are required. */ abstract protected function set_oembed_response_data( $item_id ); /** * Sets the fallback HTML for the oEmbed response. * * In a WordPress oEmbed item, the fallback HTML is a
. This is * usually hidden after the' ) + 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 2.6.0 * * @var string $retval */ return apply_filters( "bp_{$this->slug_endpoint}_embed_html", $fallback_html . $retval ); } /** * Append our custom slug endpoint to oEmbed endpoint URL. * * Meant to be used as a filter on 'rest_url' before any call to * {@link get_oembed_endpoint_url()} is used. * * @since 2.6.0 * * @see add_oembed_discovery_links() * * @param string $retval Current oEmbed endpoint URL. * @return string */ public function filter_rest_url( $retval = '' ) { return $retval . "/{$this->slug_endpoint}"; } /** * Inject content into the embed template. * * @since 2.6.0 */ public function inject_content() { if ( ! $this->is_page() ) { return; } $this->content(); } }