Code Duplication    Length = 21-21 lines in 2 locations

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

@@ 1565-1585 (lines=21) @@
1562
	 */
1563
	protected function _generate_related_post_context( $post_id ) {
1564
		$categories = get_the_category( $post_id );
1565
		if ( is_array( $categories ) ) {
1566
			foreach ( $categories as $category ) {
1567
				if ( 'uncategorized' != $category->slug && '' != trim( $category->name ) ) {
1568
					$post_cat_context = sprintf(
1569
						esc_html_x( 'In "%s"', 'in {category/tag name}', 'jetpack' ),
1570
						$category->name
1571
					);
1572
					/**
1573
					 * Filter the "In Category" line displayed in the post context below each Related Post.
1574
					 *
1575
					 * @module related-posts
1576
					 *
1577
					 * @since 3.2.0
1578
					 *
1579
					 * @param string $post_cat_context "In Category" line displayed in the post context below each Related Post.
1580
					 * @param array $category Array containing information about the category.
1581
					 */
1582
					return apply_filters( 'jetpack_relatedposts_post_category_context', $post_cat_context, $category );
1583
				}
1584
			}
1585
		}
1586
1587
		$tags = get_the_terms( $post_id, 'post_tag' );
1588
		if ( is_array( $tags ) ) {
@@ 1588-1608 (lines=21) @@
1585
		}
1586
1587
		$tags = get_the_terms( $post_id, 'post_tag' );
1588
		if ( is_array( $tags ) ) {
1589
			foreach ( $tags as $tag ) {
1590
				if ( '' != trim( $tag->name ) ) {
1591
					$post_tag_context = sprintf(
1592
						_x( 'In "%s"', 'in {category/tag name}', 'jetpack' ),
1593
						$tag->name
1594
					);
1595
					/**
1596
					 * Filter the "In Tag" line displayed in the post context below each Related Post.
1597
					 *
1598
					 * @module related-posts
1599
					 *
1600
					 * @since 3.2.0
1601
					 *
1602
					 * @param string $post_tag_context "In Tag" line displayed in the post context below each Related Post.
1603
					 * @param array $tag Array containing information about the tag.
1604
					 */
1605
					return apply_filters( 'jetpack_relatedposts_post_tag_context', $post_tag_context, $tag );
1606
				}
1607
			}
1608
		}
1609
1610
		$comment_count = get_comments_number( $post_id );
1611
		if ( $comment_count > 0 ) {