Code Duplication    Length = 21-21 lines in 2 locations

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

@@ 1145-1165 (lines=21) @@
1142
	 */
1143
	protected function _generate_related_post_context( $post_id ) {
1144
		$categories = get_the_category( $post_id );
1145
		if ( is_array( $categories ) ) {
1146
			foreach ( $categories as $category ) {
1147
				if ( 'uncategorized' != $category->slug && '' != trim( $category->name ) ) {
1148
					$post_cat_context = sprintf(
1149
						_x( 'In "%s"', 'in {category/tag name}', 'jetpack' ),
1150
						$category->name
1151
					);
1152
					/**
1153
					 * Filter the "In Category" line displayed in the post context below each Related Post.
1154
					 *
1155
					 * @module related-posts
1156
					 *
1157
					 * @since 3.2.0
1158
					 *
1159
					 * @param string $post_cat_context "In Category" line displayed in the post context below each Related Post.
1160
					 * @param array $category Array containing information about the category.
1161
					 */
1162
					return apply_filters( 'jetpack_relatedposts_post_category_context', $post_cat_context, $category );
1163
				}
1164
			}
1165
		}
1166
1167
		$tags = get_the_terms( $post_id, 'post_tag' );
1168
		if ( is_array( $tags ) ) {
@@ 1168-1188 (lines=21) @@
1165
		}
1166
1167
		$tags = get_the_terms( $post_id, 'post_tag' );
1168
		if ( is_array( $tags ) ) {
1169
			foreach ( $tags as $tag ) {
1170
				if ( '' != trim( $tag->name ) ) {
1171
					$post_tag_context = sprintf(
1172
						_x( 'In "%s"', 'in {category/tag name}', 'jetpack' ),
1173
						$tag->name
1174
					);
1175
					/**
1176
					 * Filter the "In Tag" line displayed in the post context below each Related Post.
1177
					 *
1178
					 * @module related-posts
1179
					 *
1180
					 * @since 3.2.0
1181
					 *
1182
					 * @param string $post_tag_context "In Tag" line displayed in the post context below each Related Post.
1183
					 * @param array $tag Array containing information about the tag.
1184
					 */
1185
					return apply_filters( 'jetpack_relatedposts_post_tag_context', $post_tag_context, $tag );
1186
				}
1187
			}
1188
		}
1189
1190
		$comment_count = get_comments_number( $post_id );
1191
		if ( $comment_count > 0 ) {