function comment_likes($content, $comment = null)
{
if (empty($comment)) {
return $content;
}
if (!$this->is_comments_enabled()) {
return $content;
}
$protocol = 'http';
if (is_ssl()) {
$protocol = 'https';
}
if (defined('IS_WPCOM') && IS_WPCOM) {
$blog_id = get_current_blog_id();
$bloginfo = get_blog_details((int) $blog_id);
$domain = $bloginfo->domain;
} else {
$blog_id = Jetpack_Options::get_option('id');
$url = home_url();
$url_parts = parse_url($url);
$domain = $url_parts['host'];
}
// make sure to include the scripts before the iframe otherwise weird things happen
add_action('wp_footer', array($this, 'likes_master'), 21);
$src = sprintf('%1$s://widgets.wp.com/likes/#blog_id=%2$d&comment_id=%3$d&origin=%1$s://%4$s', $protocol, $blog_id, $comment->comment_ID, $domain);
$name = sprintf('like-comment-frame-%1$d-%2$d', $blog_id, $comment->comment_ID);
$wrapper = sprintf('like-comment-wrapper-%1$d-%2$d', $blog_id, $comment->comment_ID);
$html = "<div><div class='jetpack-likes-widget-wrapper jetpack-likes-widget-unloaded' id='{$wrapper}'>";
$html .= "<iframe class='comment-likes-widget jetpack-likes-widget' name='{$name}' height='16px' width='100%' data='{$src}'></iframe>";
$html .= '</div></div>';
return $content . $html;
}