Code Duplication    Length = 39-39 lines in 2 locations

src/wp-includes/class-wp-network-query.php 1 location

@@ 292-330 (lines=39) @@
289
		$order = $this->parse_order( $this->query_vars['order'] );
290
291
		// Disable ORDER BY with 'none', an empty array, or boolean false.
292
		if ( in_array( $this->query_vars['orderby'], array( 'none', array(), false ), true ) ) {
293
			$orderby = '';
294
		} elseif ( ! empty( $this->query_vars['orderby'] ) ) {
295
			$ordersby = is_array( $this->query_vars['orderby'] ) ?
296
				$this->query_vars['orderby'] :
297
				preg_split( '/[,\s]/', $this->query_vars['orderby'] );
298
299
			$orderby_array = array();
300
			foreach ( $ordersby as $_key => $_value ) {
301
				if ( ! $_value ) {
302
					continue;
303
				}
304
305
				if ( is_int( $_key ) ) {
306
					$_orderby = $_value;
307
					$_order = $order;
308
				} else {
309
					$_orderby = $_key;
310
					$_order = $_value;
311
				}
312
313
				$parsed = $this->parse_orderby( $_orderby );
314
315
				if ( ! $parsed ) {
316
					continue;
317
				}
318
319
				if ( 'network__in' === $_orderby ) {
320
					$orderby_array[] = $parsed;
321
					continue;
322
				}
323
324
				$orderby_array[] = $parsed . ' ' . $this->parse_order( $_order );
325
			}
326
327
			$orderby = implode( ', ', $orderby_array );
328
		} else {
329
			$orderby = "$wpdb->site.id $order";
330
		}
331
332
		$number = absint( $this->query_vars['number'] );
333
		$offset = absint( $this->query_vars['offset'] );

src/wp-includes/class-wp-site-query.php 1 location

@@ 339-377 (lines=39) @@
336
		$order = $this->parse_order( $this->query_vars['order'] );
337
338
		// Disable ORDER BY with 'none', an empty array, or boolean false.
339
		if ( in_array( $this->query_vars['orderby'], array( 'none', array(), false ), true ) ) {
340
			$orderby = '';
341
		} elseif ( ! empty( $this->query_vars['orderby'] ) ) {
342
			$ordersby = is_array( $this->query_vars['orderby'] ) ?
343
				$this->query_vars['orderby'] :
344
				preg_split( '/[,\s]/', $this->query_vars['orderby'] );
345
346
			$orderby_array = array();
347
			foreach ( $ordersby as $_key => $_value ) {
348
				if ( ! $_value ) {
349
					continue;
350
				}
351
352
				if ( is_int( $_key ) ) {
353
					$_orderby = $_value;
354
					$_order = $order;
355
				} else {
356
					$_orderby = $_key;
357
					$_order = $_value;
358
				}
359
360
				$parsed = $this->parse_orderby( $_orderby );
361
362
				if ( ! $parsed ) {
363
					continue;
364
				}
365
366
				if ( 'site__in' === $_orderby || 'network__in' === $_orderby ) {
367
					$orderby_array[] = $parsed;
368
					continue;
369
				}
370
371
				$orderby_array[] = $parsed . ' ' . $this->parse_order( $_order );
372
			}
373
374
			$orderby = implode( ', ', $orderby_array );
375
		} else {
376
			$orderby = "blog_id $order";
377
		}
378
379
		$number = absint( $this->query_vars['number'] );
380
		$offset = absint( $this->query_vars['offset'] );