Code Duplication    Length = 21-21 lines in 2 locations

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

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