Slide 66
Slide 66 text
class ES_oEmbed_Comments {
function __construct() {
add_action( 'init', array( $this, 'init' ) );
}
function init() {
if ( ! is_admin() )
$this->oembed_in_comments();
}
function oembed_in_comments() {
$clickable = has_filter( 'comment_text', 'make_clickable' );
$priority = ( $clickable ) ? $clickable - 1 : 10;
add_filter( 'comment_text', array( $this, 'oembed_filter' ), $priority );
}
function oembed_filter( $comment_text ) {
global $wp_embed;
add_filter( 'embed_oembed_discover', '__return_false', 999 );
$comment_text = $wp_embed->autoembed( $comment_text );
remove_filter( 'embed_oembed_discover', '__return_false', 999 );
return $comment_text;
}
}
new ES_oEmbed_Comments;
Finished Plugin
Comment!