Code Duplication    Length = 16-16 lines in 3 locations

json-endpoints/class.wpcom-json-api-list-posts-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 ) {

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

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

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

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