Code Duplication    Length = 7-8 lines in 4 locations

includes/class-sensei-question.php 2 locations

@@ 318-325 (lines=8) @@
315
316
			// Question type
317
			$question_type = isset( $_GET['question_type'] ) ? $_GET['question_type'] : '';
318
			if( $question_type ) {
319
				$type_query = array(
320
					'taxonomy' => 'question-type',
321
					'terms' => $question_type,
322
					'field' => 'slug',
323
				);
324
				$request['tax_query'][] = $type_query;
325
			}
326
327
			// Question category
328
			$question_cat = isset( $_GET['question_cat'] ) ? $_GET['question_cat'] : '';
@@ 329-336 (lines=8) @@
326
327
			// Question category
328
			$question_cat = isset( $_GET['question_cat'] ) ? $_GET['question_cat'] : '';
329
			if( $question_cat ) {
330
				$cat_query = array(
331
					'taxonomy' => 'question-category',
332
					'terms' => $question_cat,
333
					'field' => 'slug',
334
				);
335
				$request['tax_query'][] = $cat_query;
336
			}
337
		}
338
339
		return $request;

includes/class-sensei-lesson.php 2 locations

@@ 1174-1180 (lines=7) @@
1171
			}
1172
		}
1173
1174
		if( $question_type ) {
1175
			$args['tax_query'][] = array(
1176
				'taxonomy' => 'question-type',
1177
				'field' => 'slug',
1178
				'terms' => $question_type,
1179
			);
1180
		}
1181
1182
		if( $question_category ) {
1183
			$args['tax_query'][] = array(
@@ 1182-1188 (lines=7) @@
1179
			);
1180
		}
1181
1182
		if( $question_category ) {
1183
			$args['tax_query'][] = array(
1184
				'taxonomy' => 'question-category',
1185
				'field' => 'slug',
1186
				'terms' => $question_category,
1187
			);
1188
		}
1189
1190
		if( $question_type && $question_category ) {
1191
			$args['tax_query']['relation'] = 'AND';