WordPress at a glance
function is not described

WP_Network_Query::parse_orderby() protected WP 4.6.0

Parses and sanitizes 'orderby' keys passed to the network query.

{} It's a method of the class: WP_Network_Query{}

No Hooks.

Return

String/false. Value to used in the ORDER clause. False otherwise.

Usage

// protected - for code of main (parent) or child class
$result = $this->parse_orderby( $orderby );
$orderby(string) (required)
Alias for the field to order by.

Notes

  • Global. wpdb. $wpdb WordPress database abstraction object.

Changelog

Since 4.6.0 Introduced.

Code of WP_Network_Query::parse_orderby() WP 5.5.1

<?php
protected function parse_orderby( $orderby ) {
	global $wpdb;

	$allowed_keys = array(
		'id',
		'domain',
		'path',
	);

	$parsed = false;
	if ( 'network__in' === $orderby ) {
		$network__in = implode( ',', array_map( 'absint', $this->query_vars['network__in'] ) );
		$parsed      = "FIELD( {$wpdb->site}.id, $network__in )";
	} elseif ( 'domain_length' === $orderby || 'path_length' === $orderby ) {
		$field  = substr( $orderby, 0, -7 );
		$parsed = "CHAR_LENGTH($wpdb->site.$field)";
	} elseif ( in_array( $orderby, $allowed_keys, true ) ) {
		$parsed = "$wpdb->site.$orderby";
	}

	return $parsed;
}