Code Duplication    Length = 21-21 lines in 2 locations

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

@@ 1128-1148 (lines=21) @@
1125
	 */
1126
	protected function _generate_related_post_context( $post_id ) {
1127
		$categories = get_the_category( $post_id );
1128
		if ( is_array( $categories ) ) {
1129
			foreach ( $categories as $category ) {
1130
				if ( 'uncategorized' != $category->slug && '' != trim( $category->name ) ) {
1131
					$post_cat_context = sprintf(
1132
						_x( 'In "%s"', 'in {category/tag name}', 'jetpack' ),
1133
						$category->name
1134
					);
1135
					/**
1136
					 * Filter the "In Category" line displayed in the post context below each Related Post.
1137
					 *
1138
					 * @module related-posts
1139
					 *
1140
					 * @since 3.2.0
1141
					 *
1142
					 * @param string $post_cat_context "In Category" line displayed in the post context below each Related Post.
1143
					 * @param array $category Array containing information about the category.
1144
					 */
1145
					return apply_filters( 'jetpack_relatedposts_post_category_context', $post_cat_context, $category );
1146
				}
1147
			}
1148
		}
1149
1150
		$tags = get_the_terms( $post_id, 'post_tag' );
1151
		if ( is_array( $tags ) ) {
@@ 1151-1171 (lines=21) @@
1148
		}
1149
1150
		$tags = get_the_terms( $post_id, 'post_tag' );
1151
		if ( is_array( $tags ) ) {
1152
			foreach ( $tags as $tag ) {
1153
				if ( '' != trim( $tag->name ) ) {
1154
					$post_tag_context = sprintf(
1155
						_x( 'In "%s"', 'in {category/tag name}', 'jetpack' ),
1156
						$tag->name
1157
					);
1158
					/**
1159
					 * Filter the "In Tag" line displayed in the post context below each Related Post.
1160
					 *
1161
					 * @module related-posts
1162
					 *
1163
					 * @since 3.2.0
1164
					 *
1165
					 * @param string $post_tag_context "In Tag" line displayed in the post context below each Related Post.
1166
					 * @param array $tag Array containing information about the tag.
1167
					 */
1168
					return apply_filters( 'jetpack_relatedposts_post_tag_context', $post_tag_context, $tag );
1169
				}
1170
			}
1171
		}
1172
1173
		$comment_count = get_comments_number( $post_id );
1174
		if ( $comment_count > 0 ) {