wppaste
WordPress

WP_Network_Query::get_network_ids(): int|array

Since
4.6.0
Source
wp-includes/class-wp-network-query.php:326
Used internally to get a list of network IDs matching the query vars.

Return

int|array
A single count of network IDs if a count query. An array of network IDs if a full query.

Hooks fired · 1

One hook fires while WP_Network_Query::get_network_ids() runs, in this order:

  1. apply_filters( networks_clauses )filterline 461 (+135 into the body)

    Filters the network query clauses.

Uses · 6

Used by · 1

Source

	protected function get_network_ids() {		global $wpdb; 		$order = $this->parse_order( $this->query_vars['order'] ); 		// Disable ORDER BY with 'none', an empty array, or boolean false.		if ( in_array( $this->query_vars['orderby'], array( 'none', array(), false ), true ) ) {			$orderby = '';		} elseif ( ! empty( $this->query_vars['orderby'] ) ) {			$ordersby = is_array( $this->query_vars['orderby'] ) ?				$this->query_vars['orderby'] :				preg_split( '/[,\s]/', $this->query_vars['orderby'] ); 			$orderby_array = array();			foreach ( $ordersby as $_key => $_value ) {				if ( ! $_value ) {					continue;				} 				if ( is_int( $_key ) ) {					$_orderby = $_value;					$_order   = $order;				} else {					$_orderby = $_key;					$_order   = $_value;				} 				$parsed = $this->parse_orderby( $_orderby ); 				if ( ! $parsed ) {					continue;				} 				if ( 'network__in' === $_orderby ) {					$orderby_array[] = $parsed;					continue;				} 				$orderby_array[] = $parsed . ' ' . $this->parse_order( $_order );			} 			$orderby = implode( ', ', $orderby_array );		} else {			$orderby = "$wpdb->site.id $order";		} 		$number = absint( $this->query_vars['number'] );		$offset = absint( $this->query_vars['offset'] );		$limits = ''; 		if ( ! empty( $number ) ) {			if ( $offset ) {				$limits = 'LIMIT ' . $offset . ',' . $number;			} else {				$limits = 'LIMIT ' . $number;			}		} 		if ( $this->query_vars['count'] ) {			$fields = 'COUNT(*)';		} else {			$fields = "$wpdb->site.id";		} 		// Parse network IDs for an IN clause.		if ( ! empty( $this->query_vars['network__in'] ) ) {			$this->sql_clauses['where']['network__in'] = "$wpdb->site.id IN ( " . implode( ',', wp_parse_id_list( $this->query_vars['network__in'] ) ) . ' )';		} 		// Parse network IDs for a NOT IN clause.		if ( ! empty( $this->query_vars['network__not_in'] ) ) {			$this->sql_clauses['where']['network__not_in'] = "$wpdb->site.id NOT IN ( " . implode( ',', wp_parse_id_list( $this->query_vars['network__not_in'] ) ) . ' )';		} 		if ( ! empty( $this->query_vars['domain'] ) ) {			$this->sql_clauses['where']['domain'] = $wpdb->prepare( "$wpdb->site.domain = %s", $this->query_vars['domain'] );		} 		// Parse network domain for an IN clause.		if ( is_array( $this->query_vars['domain__in'] ) ) {

History

Introduced in 4.6.0. Unchanged from 6.7.7 through 7.1.0.

  1. 6.7.7
  2. 6.8.8
  3. 6.9.7
  4. 7.0.4
  5. 7.1.0

Signature, return type and hooks compared across 5 parsed releases.

About this page

Parsed data
Generated from the wordpress-develop 6.7.7 tag, from src/wp-includes/class-wp-network-query.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.
Corrections
Something wrong on this page? Report it and it gets fixed in the next regeneration.