protected function _generate_related_post_context($post_id)
{
$categories = get_the_category($post_id);
if (is_array($categories)) {
foreach ($categories as $category) {
if ('uncategorized' != $category->slug && '' != trim($category->name)) {
$post_cat_context = sprintf(_x('In "%s"', 'in {category/tag name}', 'jetpack'), $category->name);
/**
* Filter the "In Category" line displayed in the post context below each Related Post.
*
* @module related-posts
*
* @since 3.2.0
*
* @param string $post_cat_context "In Category" line displayed in the post context below each Related Post.
* @param array $category Array containing information about the category.
*/
return apply_filters('jetpack_relatedposts_post_category_context', $post_cat_context, $category);
}
}
}
$tags = get_the_terms($post_id, 'post_tag');
if (is_array($tags)) {
foreach ($tags as $tag) {
if ('' != trim($tag->name)) {
$post_tag_context = sprintf(_x('In "%s"', 'in {category/tag name}', 'jetpack'), $tag->name);
/**
* Filter the "In Tag" line displayed in the post context below each Related Post.
*
* @module related-posts
*
* @since 3.2.0
*
* @param string $post_tag_context "In Tag" line displayed in the post context below each Related Post.
* @param array $tag Array containing information about the tag.
*/
return apply_filters('jetpack_relatedposts_post_tag_context', $post_tag_context, $tag);
}
}
}
$comment_count = get_comments_number($post_id);
if ($comment_count > 0) {
return sprintf(_n('With 1 comment', 'With %s comments', $comment_count, 'jetpack'), number_format_i18n($comment_count));
}
return __('Similar post', 'jetpack');
}