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

@@ 259-274 (lines=16) @@
256
			$query['tag'] = $args['tag'];
257
		}
258
259
		if ( ! empty( $args['term'] ) ) {
260
			$query['tax_query'] = array();
261
			foreach ( $args['term'] as $taxonomy => $slug ) {
262
				$taxonomy_object = get_taxonomy( $taxonomy );
263
				if ( false === $taxonomy_object || ( ! $taxonomy_object->public &&
264
						! current_user_can( $taxonomy_object->cap->assign_terms ) ) ) {
265
					continue;
266
				}
267
268
				$query['tax_query'][] = array(
269
					'taxonomy' => $taxonomy,
270
					'field'    => 'slug',
271
					'terms'    => explode( ',', $slug ),
272
				);
273
			}
274
		}
275
276
		if ( isset( $args['page'] ) ) {
277
			if ( $args['page'] < 1 ) {

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

@@ 253-268 (lines=16) @@
250
			$query['tag'] = $args['tag'];
251
		}
252
253
		if ( ! empty( $args['term'] ) ) {
254
			$query['tax_query'] = array();
255
			foreach ( $args['term'] as $taxonomy => $slug ) {
256
				$taxonomy_object = get_taxonomy( $taxonomy );
257
				if ( false === $taxonomy_object || ( ! $taxonomy_object->public &&
258
						! current_user_can( $taxonomy_object->cap->assign_terms ) ) ) {
259
					continue;
260
				}
261
262
				$query['tax_query'][] = array(
263
					'taxonomy' => $taxonomy,
264
					'field'    => 'slug',
265
					'terms'    => explode( ',', $slug ),
266
				);
267
			}
268
		}
269
270
		if ( isset( $args['page'] ) ) {
271
			if ( $args['page'] < 1 ) {