Code Duplication    Length = 16-16 lines in 3 locations

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

@@ 234-249 (lines=16) @@
231
			$query['tag'] = $args['tag'];
232
		}
233
234
		if ( ! empty( $args['term'] ) ) {
235
			$query['tax_query'] = array();
236
			foreach ( $args['term'] as $taxonomy => $slug ) {
237
				$taxonomy_object = get_taxonomy( $taxonomy );
238
				if ( false === $taxonomy_object || ( ! $taxonomy_object->public && 
239
						! current_user_can( $taxonomy_object->cap->assign_terms ) ) ) {
240
					continue;
241
				}
242
243
				$query['tax_query'][] = array(
244
					'taxonomy' => $taxonomy,
245
					'field' => 'slug',
246
					'terms' => explode( ',', $slug )
247
				);				
248
			}
249
		}
250
251
		if ( isset( $args['page'] ) ) {
252
			if ( $args['page'] < 1 ) {

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

@@ 243-258 (lines=16) @@
240
			$query['tag'] = $args['tag'];
241
		}
242
243
		if ( ! empty( $args['term'] ) ) {
244
			$query['tax_query'] = array();
245
			foreach ( $args['term'] as $taxonomy => $slug ) {
246
				$taxonomy_object = get_taxonomy( $taxonomy );
247
				if ( false === $taxonomy_object || ( ! $taxonomy_object->public && 
248
						! current_user_can( $taxonomy_object->cap->assign_terms ) ) ) {
249
					continue;
250
				}
251
252
				$query['tax_query'][] = array(
253
					'taxonomy' => $taxonomy,
254
					'field' => 'slug',
255
					'terms' => explode( ',', $slug )
256
				);				
257
			}
258
		}
259
260
		if ( isset( $args['page'] ) ) {
261
			if ( $args['page'] < 1 ) {

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

@@ 236-251 (lines=16) @@
233
			$query['tag'] = $args['tag'];
234
		}
235
236
		if ( ! empty( $args['term'] ) ) {
237
			$query['tax_query'] = array();
238
			foreach ( $args['term'] as $taxonomy => $slug ) {
239
				$taxonomy_object = get_taxonomy( $taxonomy );
240
				if ( false === $taxonomy_object || ( ! $taxonomy_object->public &&
241
						! current_user_can( $taxonomy_object->cap->assign_terms ) ) ) {
242
					continue;
243
				}
244
245
				$query['tax_query'][] = array(
246
					'taxonomy' => $taxonomy,
247
					'field' => 'slug',
248
					'terms' => explode( ',', $slug )
249
				);
250
			}
251
		}
252
253
		if ( isset( $args['page'] ) ) {
254
			if ( $args['page'] < 1 ) {