Code Duplication    Length = 39-39 lines in 2 locations

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

@@ 305-343 (lines=39) @@
302
		$order = $this->parse_order( $this->query_vars['order'] );
303
304
		// Disable ORDER BY with 'none', an empty array, or boolean false.
305
		if ( in_array( $this->query_vars['orderby'], array( 'none', array(), false ), true ) ) {
306
			$orderby = '';
307
		} elseif ( ! empty( $this->query_vars['orderby'] ) ) {
308
			$ordersby = is_array( $this->query_vars['orderby'] ) ?
309
				$this->query_vars['orderby'] :
310
				preg_split( '/[,\s]/', $this->query_vars['orderby'] );
311
312
			$orderby_array = array();
313
			foreach ( $ordersby as $_key => $_value ) {
314
				if ( ! $_value ) {
315
					continue;
316
				}
317
318
				if ( is_int( $_key ) ) {
319
					$_orderby = $_value;
320
					$_order = $order;
321
				} else {
322
					$_orderby = $_key;
323
					$_order = $_value;
324
				}
325
326
				$parsed = $this->parse_orderby( $_orderby );
327
328
				if ( ! $parsed ) {
329
					continue;
330
				}
331
332
				if ( 'network__in' === $_orderby ) {
333
					$orderby_array[] = $parsed;
334
					continue;
335
				}
336
337
				$orderby_array[] = $parsed . ' ' . $this->parse_order( $_order );
338
			}
339
340
			$orderby = implode( ', ', $orderby_array );
341
		} else {
342
			$orderby = "{$this->db->site}.id $order";
343
		}
344
345
		$number = absint( $this->query_vars['number'] );
346
		$offset = absint( $this->query_vars['offset'] );

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

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