107 * Sets up the site query, based on the query vars passed. |
107 * Sets up the site query, based on the query vars passed. |
108 * |
108 * |
109 * @since 4.6.0 |
109 * @since 4.6.0 |
110 * @since 4.8.0 Introduced the 'lang_id', 'lang__in', and 'lang__not_in' parameters. |
110 * @since 4.8.0 Introduced the 'lang_id', 'lang__in', and 'lang__not_in' parameters. |
111 * @since 5.1.0 Introduced the 'update_site_meta_cache', 'meta_query', 'meta_key', |
111 * @since 5.1.0 Introduced the 'update_site_meta_cache', 'meta_query', 'meta_key', |
112 * 'meta_value', 'meta_type' and 'meta_compare' parameters. |
112 * 'meta_compare_key', 'meta_value', 'meta_type', and 'meta_compare' parameters. |
|
113 * @since 5.3.0 Introduced the 'meta_type_key' parameter. |
113 * |
114 * |
114 * @param string|array $query { |
115 * @param string|array $query { |
115 * Optional. Array or query string of site query parameters. Default empty. |
116 * Optional. Array or query string of site query parameters. Default empty. |
116 * |
117 * |
117 * @type int[] $site__in Array of site IDs to include. Default empty. |
118 * @type int[] $site__in Array of site IDs to include. Default empty. |
118 * @type int[] $site__not_in Array of site IDs to exclude. Default empty. |
119 * @type int[] $site__not_in Array of site IDs to exclude. Default empty. |
119 * @type bool $count Whether to return a site count (true) or array of site objects. |
120 * @type bool $count Whether to return a site count (true) or array of site objects. |
120 * Default false. |
121 * Default false. |
121 * @type array $date_query Date query clauses to limit sites by. See WP_Date_Query. |
122 * @type array $date_query Date query clauses to limit sites by. See WP_Date_Query. |
122 * Default null. |
123 * Default null. |
123 * @type string $fields Site fields to return. Accepts 'ids' (returns an array of site IDs) |
124 * @type string $fields Site fields to return. Accepts 'ids' (returns an array of site IDs) |
124 * or empty (returns an array of complete site objects). Default empty. |
125 * or empty (returns an array of complete site objects). Default empty. |
125 * @type int $ID A site ID to only return that site. Default empty. |
126 * @type int $ID A site ID to only return that site. Default empty. |
126 * @type int $number Maximum number of sites to retrieve. Default 100. |
127 * @type int $number Maximum number of sites to retrieve. Default 100. |
127 * @type int $offset Number of sites to offset the query. Used to build LIMIT clause. |
128 * @type int $offset Number of sites to offset the query. Used to build LIMIT clause. |
128 * Default 0. |
129 * Default 0. |
129 * @type bool $no_found_rows Whether to disable the `SQL_CALC_FOUND_ROWS` query. Default true. |
130 * @type bool $no_found_rows Whether to disable the `SQL_CALC_FOUND_ROWS` query. Default true. |
130 * @type string|array $orderby Site status or array of statuses. Accepts 'id', 'domain', 'path', |
131 * @type string|array $orderby Site status or array of statuses. Accepts: |
131 * 'network_id', 'last_updated', 'registered', 'domain_length', |
132 * - 'id' |
132 * 'path_length', 'site__in' and 'network__in'. Also accepts false, |
133 * - 'domain' |
133 * an empty array, or 'none' to disable `ORDER BY` clause. |
134 * - 'path' |
134 * Default 'id'. |
135 * - 'network_id' |
135 * @type string $order How to order retrieved sites. Accepts 'ASC', 'DESC'. Default 'ASC'. |
136 * - 'last_updated' |
136 * @type int $network_id Limit results to those affiliated with a given network ID. If 0, |
137 * - 'registered' |
137 * include all networks. Default 0. |
138 * - 'domain_length' |
138 * @type int[] $network__in Array of network IDs to include affiliated sites for. Default empty. |
139 * - 'path_length' |
139 * @type int[] $network__not_in Array of network IDs to exclude affiliated sites for. Default empty. |
140 * - 'site__in' |
140 * @type string $domain Limit results to those affiliated with a given domain. Default empty. |
141 * - 'network__in' |
141 * @type string[] $domain__in Array of domains to include affiliated sites for. Default empty. |
142 * - 'deleted' |
142 * @type string[] $domain__not_in Array of domains to exclude affiliated sites for. Default empty. |
143 * - 'mature' |
143 * @type string $path Limit results to those affiliated with a given path. Default empty. |
144 * - 'spam' |
144 * @type string[] $path__in Array of paths to include affiliated sites for. Default empty. |
145 * - 'archived' |
145 * @type string[] $path__not_in Array of paths to exclude affiliated sites for. Default empty. |
146 * - 'public' |
146 * @type int $public Limit results to public sites. Accepts '1' or '0'. Default empty. |
147 * - false, an empty array, or 'none' to disable `ORDER BY` clause. |
147 * @type int $archived Limit results to archived sites. Accepts '1' or '0'. Default empty. |
148 * Default 'id'. |
148 * @type int $mature Limit results to mature sites. Accepts '1' or '0'. Default empty. |
149 * @type string $order How to order retrieved sites. Accepts 'ASC', 'DESC'. Default 'ASC'. |
149 * @type int $spam Limit results to spam sites. Accepts '1' or '0'. Default empty. |
150 * @type int $network_id Limit results to those affiliated with a given network ID. If 0, |
150 * @type int $deleted Limit results to deleted sites. Accepts '1' or '0'. Default empty. |
151 * include all networks. Default 0. |
151 * @type int $lang_id Limit results to a language ID. Default empty. |
152 * @type int[] $network__in Array of network IDs to include affiliated sites for. Default empty. |
152 * @type string[] $lang__in Array of language IDs to include affiliated sites for. Default empty. |
153 * @type int[] $network__not_in Array of network IDs to exclude affiliated sites for. Default empty. |
153 * @type string[] $lang__not_in Array of language IDs to exclude affiliated sites for. Default empty. |
154 * @type string $domain Limit results to those affiliated with a given domain. Default empty. |
154 * @type string $search Search term(s) to retrieve matching sites for. Default empty. |
155 * @type string[] $domain__in Array of domains to include affiliated sites for. Default empty. |
155 * @type string[] $search_columns Array of column names to be searched. Accepts 'domain' and 'path'. |
156 * @type string[] $domain__not_in Array of domains to exclude affiliated sites for. Default empty. |
156 * Default empty array. |
157 * @type string $path Limit results to those affiliated with a given path. Default empty. |
157 * @type bool $update_site_cache Whether to prime the cache for found sites. Default true. |
158 * @type string[] $path__in Array of paths to include affiliated sites for. Default empty. |
158 * @type bool $update_site_meta_cache Whether to prime the metadata cache for found sites. Default true. |
159 * @type string[] $path__not_in Array of paths to exclude affiliated sites for. Default empty. |
159 * @type array $meta_query Meta query clauses to limit retrieved sites by. See `WP_Meta_Query`. |
160 * @type int $public Limit results to public sites. Accepts '1' or '0'. Default empty. |
160 * Default empty. |
161 * @type int $archived Limit results to archived sites. Accepts '1' or '0'. Default empty. |
161 * @type string $meta_key Limit sites to those matching a specific metadata key. |
162 * @type int $mature Limit results to mature sites. Accepts '1' or '0'. Default empty. |
162 * Can be used in conjunction with `$meta_value`. Default empty. |
163 * @type int $spam Limit results to spam sites. Accepts '1' or '0'. Default empty. |
163 * @type string $meta_value Limit sites to those matching a specific metadata value. |
164 * @type int $deleted Limit results to deleted sites. Accepts '1' or '0'. Default empty. |
164 * Usually used in conjunction with `$meta_key`. Default empty. |
165 * @type int $lang_id Limit results to a language ID. Default empty. |
165 * @type string $meta_type Data type that the `$meta_value` column will be CAST to for |
166 * @type string[] $lang__in Array of language IDs to include affiliated sites for. Default empty. |
166 * comparisons. Default empty. |
167 * @type string[] $lang__not_in Array of language IDs to exclude affiliated sites for. Default empty. |
167 * @type string $meta_compare Comparison operator to test the `$meta_value`. Default empty. |
168 * @type string $search Search term(s) to retrieve matching sites for. Default empty. |
|
169 * @type string[] $search_columns Array of column names to be searched. Accepts 'domain' and 'path'. |
|
170 * Default empty array. |
|
171 * @type bool $update_site_cache Whether to prime the cache for found sites. Default true. |
|
172 * @type bool $update_site_meta_cache Whether to prime the metadata cache for found sites. Default true. |
|
173 * @type string|string[] $meta_key Meta key or keys to filter by. |
|
174 * @type string|string[] $meta_value Meta value or values to filter by. |
|
175 * @type string $meta_compare MySQL operator used for comparing the meta value. |
|
176 * See WP_Meta_Query::__construct for accepted values and default value. |
|
177 * @type string $meta_compare_key MySQL operator used for comparing the meta key. |
|
178 * See WP_Meta_Query::__construct for accepted values and default value. |
|
179 * @type string $meta_type MySQL data type that the meta_value column will be CAST to for comparisons. |
|
180 * See WP_Meta_Query::__construct for accepted values and default value. |
|
181 * @type string $meta_type_key MySQL data type that the meta_key column will be CAST to for comparisons. |
|
182 * See WP_Meta_Query::__construct for accepted values and default value. |
|
183 * @type array $meta_query An associative array of WP_Meta_Query arguments. |
|
184 * See WP_Meta_Query::__construct for accepted values. |
168 * } |
185 * } |
169 */ |
186 */ |
170 public function __construct( $query = '' ) { |
187 public function __construct( $query = '' ) { |
171 $this->query_var_defaults = array( |
188 $this->query_var_defaults = array( |
172 'fields' => '', |
189 'fields' => '', |