Code Duplication    Length = 8-8 lines in 3 locations

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

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

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

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

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

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