Code Duplication    Length = 21-21 lines in 2 locations

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

@@ 1247-1267 (lines=21) @@
1244
	 */
1245
	protected function _generate_related_post_context( $post_id ) {
1246
		$categories = get_the_category( $post_id );
1247
		if ( is_array( $categories ) ) {
1248
			foreach ( $categories as $category ) {
1249
				if ( 'uncategorized' != $category->slug && '' != trim( $category->name ) ) {
1250
					$post_cat_context = sprintf(
1251
						_x( 'In "%s"', 'in {category/tag name}', 'jetpack' ),
1252
						$category->name
1253
					);
1254
					/**
1255
					 * Filter the "In Category" line displayed in the post context below each Related Post.
1256
					 *
1257
					 * @module related-posts
1258
					 *
1259
					 * @since 3.2.0
1260
					 *
1261
					 * @param string $post_cat_context "In Category" line displayed in the post context below each Related Post.
1262
					 * @param array $category Array containing information about the category.
1263
					 */
1264
					return apply_filters( 'jetpack_relatedposts_post_category_context', $post_cat_context, $category );
1265
				}
1266
			}
1267
		}
1268
1269
		$tags = get_the_terms( $post_id, 'post_tag' );
1270
		if ( is_array( $tags ) ) {
@@ 1270-1290 (lines=21) @@
1267
		}
1268
1269
		$tags = get_the_terms( $post_id, 'post_tag' );
1270
		if ( is_array( $tags ) ) {
1271
			foreach ( $tags as $tag ) {
1272
				if ( '' != trim( $tag->name ) ) {
1273
					$post_tag_context = sprintf(
1274
						_x( 'In "%s"', 'in {category/tag name}', 'jetpack' ),
1275
						$tag->name
1276
					);
1277
					/**
1278
					 * Filter the "In Tag" line displayed in the post context below each Related Post.
1279
					 *
1280
					 * @module related-posts
1281
					 *
1282
					 * @since 3.2.0
1283
					 *
1284
					 * @param string $post_tag_context "In Tag" line displayed in the post context below each Related Post.
1285
					 * @param array $tag Array containing information about the tag.
1286
					 */
1287
					return apply_filters( 'jetpack_relatedposts_post_tag_context', $post_tag_context, $tag );
1288
				}
1289
			}
1290
		}
1291
1292
		$comment_count = get_comments_number( $post_id );
1293
		if ( $comment_count > 0 ) {