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

@@ 230-237 (lines=8) @@
227
			$query['post__not_in'] = isset( $query['post__not_in'] ) ? array_merge( $query['post__not_in'], $exclude_tree ) : $exclude_tree;
228
		}
229
230
		if ( isset( $args['category'] ) ) {
231
			$category = get_term_by( 'slug', $args['category'], 'category' );
232
			if ( $category === false) {
233
				$query['category_name'] = $args['category'];
234
			} else {
235
				$query['cat'] = $category->term_id;
236
			}
237
		}
238
239
		if ( isset( $args['tag'] ) ) {
240
			$query['tag'] = $args['tag'];

json-endpoints/class.wpcom-json-api-list-posts-v1-2-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'];