Edit File by line
/home/zeestwma/redstone.../wp-inclu...
File: class-wp-network-query.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* Network API: WP_Network_Query class
[2] Fix | Delete
*
[3] Fix | Delete
* @package WordPress
[4] Fix | Delete
* @subpackage Multisite
[5] Fix | Delete
* @since 4.6.0
[6] Fix | Delete
*/
[7] Fix | Delete
[8] Fix | Delete
/**
[9] Fix | Delete
* Core class used for querying networks.
[10] Fix | Delete
*
[11] Fix | Delete
* @since 4.6.0
[12] Fix | Delete
*
[13] Fix | Delete
* @see WP_Network_Query::__construct() for accepted arguments.
[14] Fix | Delete
*/
[15] Fix | Delete
#[AllowDynamicProperties]
[16] Fix | Delete
class WP_Network_Query {
[17] Fix | Delete
[18] Fix | Delete
/**
[19] Fix | Delete
* SQL for database query.
[20] Fix | Delete
*
[21] Fix | Delete
* @since 4.6.0
[22] Fix | Delete
* @var string
[23] Fix | Delete
*/
[24] Fix | Delete
public $request;
[25] Fix | Delete
[26] Fix | Delete
/**
[27] Fix | Delete
* SQL query clauses.
[28] Fix | Delete
*
[29] Fix | Delete
* @since 4.6.0
[30] Fix | Delete
* @var array
[31] Fix | Delete
*/
[32] Fix | Delete
protected $sql_clauses = array(
[33] Fix | Delete
'select' => '',
[34] Fix | Delete
'from' => '',
[35] Fix | Delete
'where' => array(),
[36] Fix | Delete
'groupby' => '',
[37] Fix | Delete
'orderby' => '',
[38] Fix | Delete
'limits' => '',
[39] Fix | Delete
);
[40] Fix | Delete
[41] Fix | Delete
/**
[42] Fix | Delete
* Query vars set by the user.
[43] Fix | Delete
*
[44] Fix | Delete
* @since 4.6.0
[45] Fix | Delete
* @var array
[46] Fix | Delete
*/
[47] Fix | Delete
public $query_vars;
[48] Fix | Delete
[49] Fix | Delete
/**
[50] Fix | Delete
* Default values for query vars.
[51] Fix | Delete
*
[52] Fix | Delete
* @since 4.6.0
[53] Fix | Delete
* @var array
[54] Fix | Delete
*/
[55] Fix | Delete
public $query_var_defaults;
[56] Fix | Delete
[57] Fix | Delete
/**
[58] Fix | Delete
* List of networks located by the query.
[59] Fix | Delete
*
[60] Fix | Delete
* @since 4.6.0
[61] Fix | Delete
* @var array
[62] Fix | Delete
*/
[63] Fix | Delete
public $networks;
[64] Fix | Delete
[65] Fix | Delete
/**
[66] Fix | Delete
* The amount of found networks for the current query.
[67] Fix | Delete
*
[68] Fix | Delete
* @since 4.6.0
[69] Fix | Delete
* @var int
[70] Fix | Delete
*/
[71] Fix | Delete
public $found_networks = 0;
[72] Fix | Delete
[73] Fix | Delete
/**
[74] Fix | Delete
* The number of pages.
[75] Fix | Delete
*
[76] Fix | Delete
* @since 4.6.0
[77] Fix | Delete
* @var int
[78] Fix | Delete
*/
[79] Fix | Delete
public $max_num_pages = 0;
[80] Fix | Delete
[81] Fix | Delete
/**
[82] Fix | Delete
* Constructor.
[83] Fix | Delete
*
[84] Fix | Delete
* Sets up the network query, based on the query vars passed.
[85] Fix | Delete
*
[86] Fix | Delete
* @since 4.6.0
[87] Fix | Delete
*
[88] Fix | Delete
* @param string|array $query {
[89] Fix | Delete
* Optional. Array or query string of network query parameters. Default empty.
[90] Fix | Delete
*
[91] Fix | Delete
* @type int[] $network__in Array of network IDs to include. Default empty.
[92] Fix | Delete
* @type int[] $network__not_in Array of network IDs to exclude. Default empty.
[93] Fix | Delete
* @type bool $count Whether to return a network count (true) or array of network objects.
[94] Fix | Delete
* Default false.
[95] Fix | Delete
* @type string $fields Network fields to return. Accepts 'ids' (returns an array of network IDs)
[96] Fix | Delete
* or empty (returns an array of complete network objects). Default empty.
[97] Fix | Delete
* @type int $number Maximum number of networks to retrieve. Default empty (no limit).
[98] Fix | Delete
* @type int $offset Number of networks to offset the query. Used to build LIMIT clause.
[99] Fix | Delete
* Default 0.
[100] Fix | Delete
* @type bool $no_found_rows Whether to disable the `SQL_CALC_FOUND_ROWS` query. Default true.
[101] Fix | Delete
* @type string|array $orderby Network status or array of statuses. Accepts 'id', 'domain', 'path',
[102] Fix | Delete
* 'domain_length', 'path_length' and 'network__in'. Also accepts false,
[103] Fix | Delete
* an empty array, or 'none' to disable `ORDER BY` clause. Default 'id'.
[104] Fix | Delete
* @type string $order How to order retrieved networks. Accepts 'ASC', 'DESC'. Default 'ASC'.
[105] Fix | Delete
* @type string $domain Limit results to those affiliated with a given domain. Default empty.
[106] Fix | Delete
* @type string[] $domain__in Array of domains to include affiliated networks for. Default empty.
[107] Fix | Delete
* @type string[] $domain__not_in Array of domains to exclude affiliated networks for. Default empty.
[108] Fix | Delete
* @type string $path Limit results to those affiliated with a given path. Default empty.
[109] Fix | Delete
* @type string[] $path__in Array of paths to include affiliated networks for. Default empty.
[110] Fix | Delete
* @type string[] $path__not_in Array of paths to exclude affiliated networks for. Default empty.
[111] Fix | Delete
* @type string $search Search term(s) to retrieve matching networks for. Default empty.
[112] Fix | Delete
* @type bool $update_network_cache Whether to prime the cache for found networks. Default true.
[113] Fix | Delete
* }
[114] Fix | Delete
*/
[115] Fix | Delete
public function __construct( $query = '' ) {
[116] Fix | Delete
$this->query_var_defaults = array(
[117] Fix | Delete
'network__in' => '',
[118] Fix | Delete
'network__not_in' => '',
[119] Fix | Delete
'count' => false,
[120] Fix | Delete
'fields' => '',
[121] Fix | Delete
'number' => '',
[122] Fix | Delete
'offset' => '',
[123] Fix | Delete
'no_found_rows' => true,
[124] Fix | Delete
'orderby' => 'id',
[125] Fix | Delete
'order' => 'ASC',
[126] Fix | Delete
'domain' => '',
[127] Fix | Delete
'domain__in' => '',
[128] Fix | Delete
'domain__not_in' => '',
[129] Fix | Delete
'path' => '',
[130] Fix | Delete
'path__in' => '',
[131] Fix | Delete
'path__not_in' => '',
[132] Fix | Delete
'search' => '',
[133] Fix | Delete
'update_network_cache' => true,
[134] Fix | Delete
);
[135] Fix | Delete
[136] Fix | Delete
if ( ! empty( $query ) ) {
[137] Fix | Delete
$this->query( $query );
[138] Fix | Delete
}
[139] Fix | Delete
}
[140] Fix | Delete
[141] Fix | Delete
/**
[142] Fix | Delete
* Parses arguments passed to the network query with default query parameters.
[143] Fix | Delete
*
[144] Fix | Delete
* @since 4.6.0
[145] Fix | Delete
*
[146] Fix | Delete
* @param string|array $query WP_Network_Query arguments. See WP_Network_Query::__construct() for accepted arguments.
[147] Fix | Delete
*/
[148] Fix | Delete
public function parse_query( $query = '' ) {
[149] Fix | Delete
if ( empty( $query ) ) {
[150] Fix | Delete
$query = $this->query_vars;
[151] Fix | Delete
}
[152] Fix | Delete
[153] Fix | Delete
$this->query_vars = wp_parse_args( $query, $this->query_var_defaults );
[154] Fix | Delete
[155] Fix | Delete
/**
[156] Fix | Delete
* Fires after the network query vars have been parsed.
[157] Fix | Delete
*
[158] Fix | Delete
* @since 4.6.0
[159] Fix | Delete
*
[160] Fix | Delete
* @param WP_Network_Query $query The WP_Network_Query instance (passed by reference).
[161] Fix | Delete
*/
[162] Fix | Delete
do_action_ref_array( 'parse_network_query', array( &$this ) );
[163] Fix | Delete
}
[164] Fix | Delete
[165] Fix | Delete
/**
[166] Fix | Delete
* Sets up the WordPress query for retrieving networks.
[167] Fix | Delete
*
[168] Fix | Delete
* @since 4.6.0
[169] Fix | Delete
*
[170] Fix | Delete
* @param string|array $query Array or URL query string of parameters.
[171] Fix | Delete
* @return array|int List of WP_Network objects, a list of network IDs when 'fields' is set to 'ids',
[172] Fix | Delete
* or the number of networks when 'count' is passed as a query var.
[173] Fix | Delete
*/
[174] Fix | Delete
public function query( $query ) {
[175] Fix | Delete
$this->query_vars = wp_parse_args( $query );
[176] Fix | Delete
return $this->get_networks();
[177] Fix | Delete
}
[178] Fix | Delete
[179] Fix | Delete
/**
[180] Fix | Delete
* Gets a list of networks matching the query vars.
[181] Fix | Delete
*
[182] Fix | Delete
* @since 4.6.0
[183] Fix | Delete
*
[184] Fix | Delete
* @return array|int List of WP_Network objects, a list of network IDs when 'fields' is set to 'ids',
[185] Fix | Delete
* or the number of networks when 'count' is passed as a query var.
[186] Fix | Delete
*/
[187] Fix | Delete
public function get_networks() {
[188] Fix | Delete
$this->parse_query();
[189] Fix | Delete
[190] Fix | Delete
/**
[191] Fix | Delete
* Fires before networks are retrieved.
[192] Fix | Delete
*
[193] Fix | Delete
* @since 4.6.0
[194] Fix | Delete
*
[195] Fix | Delete
* @param WP_Network_Query $query Current instance of WP_Network_Query (passed by reference).
[196] Fix | Delete
*/
[197] Fix | Delete
do_action_ref_array( 'pre_get_networks', array( &$this ) );
[198] Fix | Delete
[199] Fix | Delete
$network_data = null;
[200] Fix | Delete
[201] Fix | Delete
/**
[202] Fix | Delete
* Filters the network data before the query takes place.
[203] Fix | Delete
*
[204] Fix | Delete
* Return a non-null value to bypass WordPress' default network queries.
[205] Fix | Delete
*
[206] Fix | Delete
* The expected return type from this filter depends on the value passed
[207] Fix | Delete
* in the request query vars:
[208] Fix | Delete
* - When `$this->query_vars['count']` is set, the filter should return
[209] Fix | Delete
* the network count as an integer.
[210] Fix | Delete
* - When `'ids' === $this->query_vars['fields']`, the filter should return
[211] Fix | Delete
* an array of network IDs.
[212] Fix | Delete
* - Otherwise the filter should return an array of WP_Network objects.
[213] Fix | Delete
*
[214] Fix | Delete
* Note that if the filter returns an array of network data, it will be assigned
[215] Fix | Delete
* to the `networks` property of the current WP_Network_Query instance.
[216] Fix | Delete
*
[217] Fix | Delete
* Filtering functions that require pagination information are encouraged to set
[218] Fix | Delete
* the `found_networks` and `max_num_pages` properties of the WP_Network_Query object,
[219] Fix | Delete
* passed to the filter by reference. If WP_Network_Query does not perform a database
[220] Fix | Delete
* query, it will not have enough information to generate these values itself.
[221] Fix | Delete
*
[222] Fix | Delete
* @since 5.2.0
[223] Fix | Delete
* @since 5.6.0 The returned array of network data is assigned to the `networks` property
[224] Fix | Delete
* of the current WP_Network_Query instance.
[225] Fix | Delete
*
[226] Fix | Delete
* @param array|int|null $network_data Return an array of network data to short-circuit WP's network query,
[227] Fix | Delete
* the network count as an integer if `$this->query_vars['count']` is set,
[228] Fix | Delete
* or null to allow WP to run its normal queries.
[229] Fix | Delete
* @param WP_Network_Query $query The WP_Network_Query instance, passed by reference.
[230] Fix | Delete
*/
[231] Fix | Delete
$network_data = apply_filters_ref_array( 'networks_pre_query', array( $network_data, &$this ) );
[232] Fix | Delete
[233] Fix | Delete
if ( null !== $network_data ) {
[234] Fix | Delete
if ( is_array( $network_data ) && ! $this->query_vars['count'] ) {
[235] Fix | Delete
$this->networks = $network_data;
[236] Fix | Delete
}
[237] Fix | Delete
[238] Fix | Delete
return $network_data;
[239] Fix | Delete
}
[240] Fix | Delete
[241] Fix | Delete
// $args can include anything. Only use the args defined in the query_var_defaults to compute the key.
[242] Fix | Delete
$_args = wp_array_slice_assoc( $this->query_vars, array_keys( $this->query_var_defaults ) );
[243] Fix | Delete
[244] Fix | Delete
// Ignore the $fields, $update_network_cache arguments as the queried result will be the same regardless.
[245] Fix | Delete
unset( $_args['fields'], $_args['update_network_cache'] );
[246] Fix | Delete
[247] Fix | Delete
$key = md5( serialize( $_args ) );
[248] Fix | Delete
$last_changed = wp_cache_get_last_changed( 'networks' );
[249] Fix | Delete
[250] Fix | Delete
$cache_key = "get_network_ids:$key";
[251] Fix | Delete
$cache_value = wp_cache_get_salted( $cache_key, 'network-queries', $last_changed );
[252] Fix | Delete
[253] Fix | Delete
if ( false === $cache_value ) {
[254] Fix | Delete
$network_ids = $this->get_network_ids();
[255] Fix | Delete
if ( $network_ids ) {
[256] Fix | Delete
$this->set_found_networks();
[257] Fix | Delete
}
[258] Fix | Delete
[259] Fix | Delete
$cache_value = array(
[260] Fix | Delete
'network_ids' => $network_ids,
[261] Fix | Delete
'found_networks' => $this->found_networks,
[262] Fix | Delete
);
[263] Fix | Delete
wp_cache_set_salted( $cache_key, $cache_value, 'network-queries', $last_changed );
[264] Fix | Delete
} else {
[265] Fix | Delete
$network_ids = $cache_value['network_ids'];
[266] Fix | Delete
$this->found_networks = $cache_value['found_networks'];
[267] Fix | Delete
}
[268] Fix | Delete
[269] Fix | Delete
if ( $this->found_networks && $this->query_vars['number'] ) {
[270] Fix | Delete
$this->max_num_pages = (int) ceil( $this->found_networks / $this->query_vars['number'] );
[271] Fix | Delete
}
[272] Fix | Delete
[273] Fix | Delete
// If querying for a count only, there's nothing more to do.
[274] Fix | Delete
if ( $this->query_vars['count'] ) {
[275] Fix | Delete
// $network_ids is actually a count in this case.
[276] Fix | Delete
return (int) $network_ids;
[277] Fix | Delete
}
[278] Fix | Delete
[279] Fix | Delete
$network_ids = array_map( 'intval', $network_ids );
[280] Fix | Delete
[281] Fix | Delete
if ( 'ids' === $this->query_vars['fields'] ) {
[282] Fix | Delete
$this->networks = $network_ids;
[283] Fix | Delete
return $this->networks;
[284] Fix | Delete
}
[285] Fix | Delete
[286] Fix | Delete
if ( $this->query_vars['update_network_cache'] ) {
[287] Fix | Delete
_prime_network_caches( $network_ids );
[288] Fix | Delete
}
[289] Fix | Delete
[290] Fix | Delete
// Fetch full network objects from the primed cache.
[291] Fix | Delete
$_networks = array();
[292] Fix | Delete
foreach ( $network_ids as $network_id ) {
[293] Fix | Delete
$_network = get_network( $network_id );
[294] Fix | Delete
if ( $_network ) {
[295] Fix | Delete
$_networks[] = $_network;
[296] Fix | Delete
}
[297] Fix | Delete
}
[298] Fix | Delete
[299] Fix | Delete
/**
[300] Fix | Delete
* Filters the network query results.
[301] Fix | Delete
*
[302] Fix | Delete
* @since 4.6.0
[303] Fix | Delete
*
[304] Fix | Delete
* @param WP_Network[] $_networks An array of WP_Network objects.
[305] Fix | Delete
* @param WP_Network_Query $query Current instance of WP_Network_Query (passed by reference).
[306] Fix | Delete
*/
[307] Fix | Delete
$_networks = apply_filters_ref_array( 'the_networks', array( $_networks, &$this ) );
[308] Fix | Delete
[309] Fix | Delete
// Convert to WP_Network instances.
[310] Fix | Delete
$this->networks = array_map( 'get_network', $_networks );
[311] Fix | Delete
[312] Fix | Delete
return $this->networks;
[313] Fix | Delete
}
[314] Fix | Delete
[315] Fix | Delete
/**
[316] Fix | Delete
* Used internally to get a list of network IDs matching the query vars.
[317] Fix | Delete
*
[318] Fix | Delete
* @since 4.6.0
[319] Fix | Delete
*
[320] Fix | Delete
* @global wpdb $wpdb WordPress database abstraction object.
[321] Fix | Delete
*
[322] Fix | Delete
* @return int|array A single count of network IDs if a count query. An array of network IDs if a full query.
[323] Fix | Delete
*/
[324] Fix | Delete
protected function get_network_ids() {
[325] Fix | Delete
global $wpdb;
[326] Fix | Delete
[327] Fix | Delete
$order = $this->parse_order( $this->query_vars['order'] );
[328] Fix | Delete
[329] Fix | Delete
// Disable ORDER BY with 'none', an empty array, or boolean false.
[330] Fix | Delete
if ( in_array( $this->query_vars['orderby'], array( 'none', array(), false ), true ) ) {
[331] Fix | Delete
$orderby = '';
[332] Fix | Delete
} elseif ( ! empty( $this->query_vars['orderby'] ) ) {
[333] Fix | Delete
$ordersby = is_array( $this->query_vars['orderby'] ) ?
[334] Fix | Delete
$this->query_vars['orderby'] :
[335] Fix | Delete
preg_split( '/[,\s]/', $this->query_vars['orderby'] );
[336] Fix | Delete
[337] Fix | Delete
$orderby_array = array();
[338] Fix | Delete
foreach ( $ordersby as $_key => $_value ) {
[339] Fix | Delete
if ( ! $_value ) {
[340] Fix | Delete
continue;
[341] Fix | Delete
}
[342] Fix | Delete
[343] Fix | Delete
if ( is_int( $_key ) ) {
[344] Fix | Delete
$_orderby = $_value;
[345] Fix | Delete
$_order = $order;
[346] Fix | Delete
} else {
[347] Fix | Delete
$_orderby = $_key;
[348] Fix | Delete
$_order = $_value;
[349] Fix | Delete
}
[350] Fix | Delete
[351] Fix | Delete
$parsed = $this->parse_orderby( $_orderby );
[352] Fix | Delete
[353] Fix | Delete
if ( ! $parsed ) {
[354] Fix | Delete
continue;
[355] Fix | Delete
}
[356] Fix | Delete
[357] Fix | Delete
if ( 'network__in' === $_orderby ) {
[358] Fix | Delete
$orderby_array[] = $parsed;
[359] Fix | Delete
continue;
[360] Fix | Delete
}
[361] Fix | Delete
[362] Fix | Delete
$orderby_array[] = $parsed . ' ' . $this->parse_order( $_order );
[363] Fix | Delete
}
[364] Fix | Delete
[365] Fix | Delete
$orderby = implode( ', ', $orderby_array );
[366] Fix | Delete
} else {
[367] Fix | Delete
$orderby = "$wpdb->site.id $order";
[368] Fix | Delete
}
[369] Fix | Delete
[370] Fix | Delete
$number = absint( $this->query_vars['number'] );
[371] Fix | Delete
$offset = absint( $this->query_vars['offset'] );
[372] Fix | Delete
$limits = '';
[373] Fix | Delete
[374] Fix | Delete
if ( ! empty( $number ) ) {
[375] Fix | Delete
if ( $offset ) {
[376] Fix | Delete
$limits = 'LIMIT ' . $offset . ',' . $number;
[377] Fix | Delete
} else {
[378] Fix | Delete
$limits = 'LIMIT ' . $number;
[379] Fix | Delete
}
[380] Fix | Delete
}
[381] Fix | Delete
[382] Fix | Delete
if ( $this->query_vars['count'] ) {
[383] Fix | Delete
$fields = 'COUNT(*)';
[384] Fix | Delete
} else {
[385] Fix | Delete
$fields = "$wpdb->site.id";
[386] Fix | Delete
}
[387] Fix | Delete
[388] Fix | Delete
// Parse network IDs for an IN clause.
[389] Fix | Delete
if ( ! empty( $this->query_vars['network__in'] ) ) {
[390] Fix | Delete
$this->sql_clauses['where']['network__in'] = "$wpdb->site.id IN ( " . implode( ',', wp_parse_id_list( $this->query_vars['network__in'] ) ) . ' )';
[391] Fix | Delete
}
[392] Fix | Delete
[393] Fix | Delete
// Parse network IDs for a NOT IN clause.
[394] Fix | Delete
if ( ! empty( $this->query_vars['network__not_in'] ) ) {
[395] Fix | Delete
$this->sql_clauses['where']['network__not_in'] = "$wpdb->site.id NOT IN ( " . implode( ',', wp_parse_id_list( $this->query_vars['network__not_in'] ) ) . ' )';
[396] Fix | Delete
}
[397] Fix | Delete
[398] Fix | Delete
if ( ! empty( $this->query_vars['domain'] ) ) {
[399] Fix | Delete
$this->sql_clauses['where']['domain'] = $wpdb->prepare( "$wpdb->site.domain = %s", $this->query_vars['domain'] );
[400] Fix | Delete
}
[401] Fix | Delete
[402] Fix | Delete
// Parse network domain for an IN clause.
[403] Fix | Delete
if ( is_array( $this->query_vars['domain__in'] ) ) {
[404] Fix | Delete
$this->sql_clauses['where']['domain__in'] = "$wpdb->site.domain IN ( '" . implode( "', '", $wpdb->_escape( $this->query_vars['domain__in'] ) ) . "' )";
[405] Fix | Delete
}
[406] Fix | Delete
[407] Fix | Delete
// Parse network domain for a NOT IN clause.
[408] Fix | Delete
if ( is_array( $this->query_vars['domain__not_in'] ) ) {
[409] Fix | Delete
$this->sql_clauses['where']['domain__not_in'] = "$wpdb->site.domain NOT IN ( '" . implode( "', '", $wpdb->_escape( $this->query_vars['domain__not_in'] ) ) . "' )";
[410] Fix | Delete
}
[411] Fix | Delete
[412] Fix | Delete
if ( ! empty( $this->query_vars['path'] ) ) {
[413] Fix | Delete
$this->sql_clauses['where']['path'] = $wpdb->prepare( "$wpdb->site.path = %s", $this->query_vars['path'] );
[414] Fix | Delete
}
[415] Fix | Delete
[416] Fix | Delete
// Parse network path for an IN clause.
[417] Fix | Delete
if ( is_array( $this->query_vars['path__in'] ) ) {
[418] Fix | Delete
$this->sql_clauses['where']['path__in'] = "$wpdb->site.path IN ( '" . implode( "', '", $wpdb->_escape( $this->query_vars['path__in'] ) ) . "' )";
[419] Fix | Delete
}
[420] Fix | Delete
[421] Fix | Delete
// Parse network path for a NOT IN clause.
[422] Fix | Delete
if ( is_array( $this->query_vars['path__not_in'] ) ) {
[423] Fix | Delete
$this->sql_clauses['where']['path__not_in'] = "$wpdb->site.path NOT IN ( '" . implode( "', '", $wpdb->_escape( $this->query_vars['path__not_in'] ) ) . "' )";
[424] Fix | Delete
}
[425] Fix | Delete
[426] Fix | Delete
// Falsey search strings are ignored.
[427] Fix | Delete
if ( strlen( $this->query_vars['search'] ) ) {
[428] Fix | Delete
$this->sql_clauses['where']['search'] = $this->get_search_sql(
[429] Fix | Delete
$this->query_vars['search'],
[430] Fix | Delete
array( "$wpdb->site.domain", "$wpdb->site.path" )
[431] Fix | Delete
);
[432] Fix | Delete
}
[433] Fix | Delete
[434] Fix | Delete
$join = '';
[435] Fix | Delete
[436] Fix | Delete
$where = implode( ' AND ', $this->sql_clauses['where'] );
[437] Fix | Delete
[438] Fix | Delete
$groupby = '';
[439] Fix | Delete
[440] Fix | Delete
$pieces = array( 'fields', 'join', 'where', 'orderby', 'limits', 'groupby' );
[441] Fix | Delete
[442] Fix | Delete
/**
[443] Fix | Delete
* Filters the network query clauses.
[444] Fix | Delete
*
[445] Fix | Delete
* @since 4.6.0
[446] Fix | Delete
*
[447] Fix | Delete
* @param string[] $clauses {
[448] Fix | Delete
* Associative array of the clauses for the query.
[449] Fix | Delete
*
[450] Fix | Delete
* @type string $fields The SELECT clause of the query.
[451] Fix | Delete
* @type string $join The JOIN clause of the query.
[452] Fix | Delete
* @type string $where The WHERE clause of the query.
[453] Fix | Delete
* @type string $orderby The ORDER BY clause of the query.
[454] Fix | Delete
* @type string $limits The LIMIT clause of the query.
[455] Fix | Delete
* @type string $groupby The GROUP BY clause of the query.
[456] Fix | Delete
* }
[457] Fix | Delete
* @param WP_Network_Query $query Current instance of WP_Network_Query (passed by reference).
[458] Fix | Delete
*/
[459] Fix | Delete
$clauses = apply_filters_ref_array( 'networks_clauses', array( compact( $pieces ), &$this ) );
[460] Fix | Delete
[461] Fix | Delete
$fields = isset( $clauses['fields'] ) ? $clauses['fields'] : '';
[462] Fix | Delete
$join = isset( $clauses['join'] ) ? $clauses['join'] : '';
[463] Fix | Delete
$where = isset( $clauses['where'] ) ? $clauses['where'] : '';
[464] Fix | Delete
$orderby = isset( $clauses['orderby'] ) ? $clauses['orderby'] : '';
[465] Fix | Delete
$limits = isset( $clauses['limits'] ) ? $clauses['limits'] : '';
[466] Fix | Delete
$groupby = isset( $clauses['groupby'] ) ? $clauses['groupby'] : '';
[467] Fix | Delete
[468] Fix | Delete
if ( $where ) {
[469] Fix | Delete
$where = 'WHERE ' . $where;
[470] Fix | Delete
}
[471] Fix | Delete
[472] Fix | Delete
if ( $groupby ) {
[473] Fix | Delete
$groupby = 'GROUP BY ' . $groupby;
[474] Fix | Delete
}
[475] Fix | Delete
[476] Fix | Delete
if ( $orderby ) {
[477] Fix | Delete
$orderby = "ORDER BY $orderby";
[478] Fix | Delete
}
[479] Fix | Delete
[480] Fix | Delete
$found_rows = '';
[481] Fix | Delete
if ( ! $this->query_vars['no_found_rows'] ) {
[482] Fix | Delete
$found_rows = 'SQL_CALC_FOUND_ROWS';
[483] Fix | Delete
}
[484] Fix | Delete
[485] Fix | Delete
$this->sql_clauses['select'] = "SELECT $found_rows $fields";
[486] Fix | Delete
$this->sql_clauses['from'] = "FROM $wpdb->site $join";
[487] Fix | Delete
$this->sql_clauses['groupby'] = $groupby;
[488] Fix | Delete
$this->sql_clauses['orderby'] = $orderby;
[489] Fix | Delete
$this->sql_clauses['limits'] = $limits;
[490] Fix | Delete
[491] Fix | Delete
// Beginning of the string is on a new line to prevent leading whitespace. See https://core.trac.wordpress.org/ticket/56841.
[492] Fix | Delete
$this->request =
[493] Fix | Delete
"{$this->sql_clauses['select']}
[494] Fix | Delete
{$this->sql_clauses['from']}
[495] Fix | Delete
{$where}
[496] Fix | Delete
{$this->sql_clauses['groupby']}
[497] Fix | Delete
{$this->sql_clauses['orderby']}
[498] Fix | Delete
{$this->sql_clauses['limits']}";
[499] Fix | Delete
12
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function