Code Duplication    Length = 16-16 lines in 3 locations

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

@@ 175-190 (lines=16) @@
172
			$query['tag'] = $args['tag'];
173
		}
174
175
		if ( ! empty( $args['term'] ) ) {
176
			$query['tax_query'] = array();
177
			foreach ( $args['term'] as $taxonomy => $slug ) {
178
				$taxonomy_object = get_taxonomy( $taxonomy );
179
				if ( false === $taxonomy_object || ( ! $taxonomy_object->public && 
180
						! current_user_can( $taxonomy_object->cap->assign_terms ) ) ) {
181
					continue;
182
				}
183
184
				$query['tax_query'][] = array(
185
					'taxonomy' => $taxonomy,
186
					'field' => 'slug',
187
					'terms' => explode( ',', $slug )
188
				);				
189
			}
190
		}
191
192
		if ( isset( $args['page'] ) ) {
193
			if ( $args['page'] < 1 ) {

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

@@ 187-202 (lines=16) @@
184
			$query['tag'] = $args['tag'];
185
		}
186
187
		if ( ! empty( $args['term'] ) ) {
188
			$query['tax_query'] = array();
189
			foreach ( $args['term'] as $taxonomy => $slug ) {
190
				$taxonomy_object = get_taxonomy( $taxonomy );
191
				if ( false === $taxonomy_object || ( ! $taxonomy_object->public && 
192
						! current_user_can( $taxonomy_object->cap->assign_terms ) ) ) {
193
					continue;
194
				}
195
196
				$query['tax_query'][] = array(
197
					'taxonomy' => $taxonomy,
198
					'field' => 'slug',
199
					'terms' => explode( ',', $slug )
200
				);				
201
			}
202
		}
203
204
		if ( isset( $args['page'] ) ) {
205
			if ( $args['page'] < 1 ) {

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

@@ 185-200 (lines=16) @@
182
			$query['tag'] = $args['tag'];
183
		}
184
185
		if ( ! empty( $args['term'] ) ) {
186
			$query['tax_query'] = array();
187
			foreach ( $args['term'] as $taxonomy => $slug ) {
188
				$taxonomy_object = get_taxonomy( $taxonomy );
189
				if ( false === $taxonomy_object || ( ! $taxonomy_object->public &&
190
						! current_user_can( $taxonomy_object->cap->assign_terms ) ) ) {
191
					continue;
192
				}
193
194
				$query['tax_query'][] = array(
195
					'taxonomy' => $taxonomy,
196
					'field' => 'slug',
197
					'terms' => explode( ',', $slug )
198
				);
199
			}
200
		}
201
202
		if ( isset( $args['page'] ) ) {
203
			if ( $args['page'] < 1 ) {