Code Duplication    Length = 21-21 lines in 2 locations

modules/related-posts/jetpack-related-posts.php 2 locations

@@ 1545-1565 (lines=21) @@
1542
	 */
1543
	protected function _generate_related_post_context( $post_id ) {
1544
		$categories = get_the_category( $post_id );
1545
		if ( is_array( $categories ) ) {
1546
			foreach ( $categories as $category ) {
1547
				if ( 'uncategorized' != $category->slug && '' != trim( $category->name ) ) {
1548
					$post_cat_context = sprintf(
1549
						esc_html_x( 'In "%s"', 'in {category/tag name}', 'jetpack' ),
1550
						$category->name
1551
					);
1552
					/**
1553
					 * Filter the "In Category" line displayed in the post context below each Related Post.
1554
					 *
1555
					 * @module related-posts
1556
					 *
1557
					 * @since 3.2.0
1558
					 *
1559
					 * @param string $post_cat_context "In Category" line displayed in the post context below each Related Post.
1560
					 * @param array $category Array containing information about the category.
1561
					 */
1562
					return apply_filters( 'jetpack_relatedposts_post_category_context', $post_cat_context, $category );
1563
				}
1564
			}
1565
		}
1566
1567
		$tags = get_the_terms( $post_id, 'post_tag' );
1568
		if ( is_array( $tags ) ) {
@@ 1568-1588 (lines=21) @@
1565
		}
1566
1567
		$tags = get_the_terms( $post_id, 'post_tag' );
1568
		if ( is_array( $tags ) ) {
1569
			foreach ( $tags as $tag ) {
1570
				if ( '' != trim( $tag->name ) ) {
1571
					$post_tag_context = sprintf(
1572
						_x( 'In "%s"', 'in {category/tag name}', 'jetpack' ),
1573
						$tag->name
1574
					);
1575
					/**
1576
					 * Filter the "In Tag" line displayed in the post context below each Related Post.
1577
					 *
1578
					 * @module related-posts
1579
					 *
1580
					 * @since 3.2.0
1581
					 *
1582
					 * @param string $post_tag_context "In Tag" line displayed in the post context below each Related Post.
1583
					 * @param array $tag Array containing information about the tag.
1584
					 */
1585
					return apply_filters( 'jetpack_relatedposts_post_tag_context', $post_tag_context, $tag );
1586
				}
1587
			}
1588
		}
1589
1590
		$comment_count = get_comments_number( $post_id );
1591
		if ( $comment_count > 0 ) {