Code Duplication    Length = 8-8 lines in 3 locations

json-endpoints/class.wpcom-json-api-list-posts-endpoint.php 1 location

@@ 221-228 (lines=8) @@
218
			$query['post__not_in'] = isset( $query['post__not_in'] ) ? array_merge( $query['post__not_in'], $exclude_tree ) : $exclude_tree;
219
		}
220
221
		if ( isset( $args['category'] ) ) {
222
			$category = get_term_by( 'slug', $args['category'], 'category' );
223
			if ( $category === false) {
224
				$query['category_name'] = $args['category'];
225
			} else {
226
				$query['cat'] = $category->term_id;
227
			}
228
		}
229
230
		if ( isset( $args['tag'] ) ) {
231
			$query['tag'] = $args['tag'];

json-endpoints/class.wpcom-json-api-list-posts-v1-1-endpoint.php 1 location

@@ 246-253 (lines=8) @@
243
			$query['post__not_in'] = isset( $query['post__not_in'] ) ? array_merge( $query['post__not_in'], $exclude_tree ) : $exclude_tree;
244
		}
245
246
		if ( isset( $args['category'] ) ) {
247
			$category = get_term_by( 'slug', $args['category'], 'category' );
248
			if ( $category === false ) {
249
				$query['category_name'] = $args['category'];
250
			} else {
251
				$query['cat'] = $category->term_id;
252
			}
253
		}
254
255
		if ( isset( $args['tag'] ) ) {
256
			$query['tag'] = $args['tag'];

json-endpoints/class.wpcom-json-api-list-posts-v1-2-endpoint.php 1 location

@@ 240-247 (lines=8) @@
237
			$query['post__not_in'] = isset( $query['post__not_in'] ) ? array_merge( $query['post__not_in'], $exclude_tree ) : $exclude_tree;
238
		}
239
240
		if ( isset( $args['category'] ) ) {
241
			$category = get_term_by( 'slug', $args['category'], 'category' );
242
			if ( $category === false ) {
243
				$query['category_name'] = $args['category'];
244
			} else {
245
				$query['cat'] = $category->term_id;
246
			}
247
		}
248
249
		if ( isset( $args['tag'] ) ) {
250
			$query['tag'] = $args['tag'];