/** * Add autoembed filters for bbPress to BuddyPress' Embeds handler. * * Piggyback off of BuddyPress' {@link BP_Embed} class as it is less * restrictive than WordPress' {@link WP_Embed} class. * * Runs on AJAX only. */ public function autoembed_hacks($embed) { // if we're not running AJAX, we don't need to do this if (!defined('DOING_AJAX')) { return; } // make sure bbP allows autoembeds if (bbp_use_autoembed()) { // replies add_filter('bbp_get_reply_content', array($embed, 'autoembed'), 2); add_filter('bbp_get_reply_content', array($embed, 'run_shortcode'), 1); // topics add_filter('bbp_get_topic_content', array($embed, 'autoembed'), 2); add_filter('bbp_get_topic_content', array($embed, 'run_shortcode'), 1); } }
/** * Check if autoembeds are enabled and hook them in if so * * @since bbPress (r3752) * @global WP_Embed $wp_embed */ function bbp_topic_content_autoembed() { global $wp_embed; if (bbp_use_autoembed() && is_a($wp_embed, 'WP_Embed')) { add_filter('bbp_get_topic_content', array($wp_embed, 'autoembed'), 2); } }
/** * Allow oEmbed in replies * * @since 2.1.0 bbPress (r3752) * * @uses checked() To display the checked attribute */ function bbp_admin_setting_callback_use_autoembed() { ?> <input name="_bbp_use_autoembed" id="_bbp_use_autoembed" type="checkbox" value="1" <?php checked(bbp_use_autoembed(true)); bbp_maybe_admin_setting_disabled('_bbp_use_autoembed'); ?> /> <label for="_bbp_use_autoembed"><?php esc_html_e('Embed media (YouTube, Twitter, Flickr, etc...) directly into topics and replies', 'bbpress'); ?> </label> <?php }