WP_Site_Query::__construct()publicWP 4.6.0

Sets up the site query, based on the query vars passed.

Метод класса: WP_Site_Query{}

Хуков нет.

Возвращает

null. Ничего (null).

Использование

$WP_Site_Query = new WP_Site_Query();
$WP_Site_Query->__construct( $query );
$query(строка|массив)

Array or query string of site query parameters.

По умолчанию: ''

  • site__in(int[])
    Array of site IDs to include.
    По умолчанию: ''

  • site__not_in(int[])
    Array of site IDs to exclude.
    По умолчанию: ''

  • count(true|false)
    Whether to return a site count (true) or array of site objects.
    По умолчанию: false

  • date_query(массив)
    Date query clauses to limit sites by. See WP_Date_Query.
    По умолчанию: null

  • fields(строка)
    Site fields to return. Accepts 'ids' (returns an array of site IDs) or empty (returns an array of complete site objects).
    По умолчанию: ''

  • ID(int)
    A site ID to only return that site.
    По умолчанию: ''

  • number(int)
    Maximum number of sites to retrieve.
    По умолчанию: 100

  • offset(int)
    Number of sites to offset the query. Used to build LIMIT clause.

  • no_found_rows(true|false)
    Whether to disable the SQL_CALC_FOUND_ROWS query.
    По умолчанию: true

  • orderby(строка|массив)
    Site status or array of statuses. Accepts:

    • 'id'
    • 'domain'
    • 'path'
    • 'network_id'
    • 'last_updated'
    • 'registered'
    • 'domain_length'
    • 'path_length'
    • 'site__in'
    • 'network__in'
    • 'deleted'
    • 'mature'
    • 'spam'
    • 'archived'
    • 'public'
    • false, an empty array, or 'none' to disable ORDER BY clause.
      По умолчанию: 'id'
  • order(строка)
    How to order retrieved sites. Accepts 'ASC', 'DESC'.
    По умолчанию: 'ASC'

  • network_id(int)
    Limit results to those affiliated with a given network ID. If 0, include all networks.

  • network__in(int[])
    Array of network IDs to include affiliated sites for.
    По умолчанию: ''

  • network__not_in(int[])
    Array of network IDs to exclude affiliated sites for.
    По умолчанию: ''

  • domain(строка)
    Limit results to those affiliated with a given domain.
    По умолчанию: ''

  • domain__in(string[])
    Array of domains to include affiliated sites for.
    По умолчанию: ''

  • domain__not_in(string[])
    Array of domains to exclude affiliated sites for.
    По умолчанию: ''

  • path(строка)
    Limit results to those affiliated with a given path.
    По умолчанию: ''

  • path__in(string[])
    Array of paths to include affiliated sites for.
    По умолчанию: ''

  • path__not_in(string[])
    Array of paths to exclude affiliated sites for.
    По умолчанию: ''

  • public(int)
    Limit results to public sites. Accepts 1 or 0.
    По умолчанию: ''

  • archived(int)
    Limit results to archived sites. Accepts 1 or 0.
    По умолчанию: ''

  • mature(int)
    Limit results to mature sites. Accepts 1 or 0.
    По умолчанию: ''

  • spam(int)
    Limit results to spam sites. Accepts 1 or 0.
    По умолчанию: ''

  • deleted(int)
    Limit results to deleted sites. Accepts 1 or 0.
    По умолчанию: ''

  • lang_id(int)
    Limit results to a language ID.
    По умолчанию: ''

  • lang__in(string[])
    Array of language IDs to include affiliated sites for.
    По умолчанию: ''

  • lang__not_in(string[])
    Array of language IDs to exclude affiliated sites for.
    По умолчанию: ''

  • search(строка)
    Search term(s) to retrieve matching sites for.
    По умолчанию: ''

  • search_columns(string[])
    Array of column names to be searched. Accepts 'domain' and 'path'.
    По умолчанию: empty array

  • update_site_cache(true|false)
    Whether to prime the cache for found sites.
    По умолчанию: true

  • update_site_meta_cache(true|false)
    Whether to prime the metadata cache for found sites.
    По умолчанию: true

  • meta_key(строка|string[])
    Meta key or keys to filter by.

  • meta_value(строка|string[])
    Meta value or values to filter by.

  • meta_compare(строка)
    MySQL operator used for comparing the meta value. See WP_Meta_Query::__construct() for accepted values and default value.

  • meta_compare_key(строка)
    MySQL operator used for comparing the meta key. See WP_Meta_Query::__construct() for accepted values and default value.

  • meta_type(строка)
    MySQL data type that the meta_value column will be CAST to for comparisons. See WP_Meta_Query::__construct() for accepted values and default value.

  • meta_type_key(строка)
    MySQL data type that the meta_key column will be CAST to for comparisons. See WP_Meta_Query::__construct() for accepted values and default value.

  • meta_query(массив)
    An associative array of WP_Meta_Query arguments. See WP_Meta_Query::__construct() for accepted values.

Список изменений

С версии 4.6.0 Введена.
С версии 4.8.0 Introduced the 'lang_id', 'lang__in', and 'lang__not_in' parameters.
С версии 5.1.0 Introduced the 'update_site_meta_cache', 'meta_query', 'meta_key', 'meta_compare_key', 'meta_value', 'meta_type', and 'meta_compare' parameters.
С версии 5.3.0 Introduced the 'meta_type_key' parameter.

Код WP_Site_Query::__construct() WP 6.5.2

public function __construct( $query = '' ) {
	$this->query_var_defaults = array(
		'fields'                 => '',
		'ID'                     => '',
		'site__in'               => '',
		'site__not_in'           => '',
		'number'                 => 100,
		'offset'                 => '',
		'no_found_rows'          => true,
		'orderby'                => 'id',
		'order'                  => 'ASC',
		'network_id'             => 0,
		'network__in'            => '',
		'network__not_in'        => '',
		'domain'                 => '',
		'domain__in'             => '',
		'domain__not_in'         => '',
		'path'                   => '',
		'path__in'               => '',
		'path__not_in'           => '',
		'public'                 => null,
		'archived'               => null,
		'mature'                 => null,
		'spam'                   => null,
		'deleted'                => null,
		'lang_id'                => null,
		'lang__in'               => '',
		'lang__not_in'           => '',
		'search'                 => '',
		'search_columns'         => array(),
		'count'                  => false,
		'date_query'             => null, // See WP_Date_Query.
		'update_site_cache'      => true,
		'update_site_meta_cache' => true,
		'meta_query'             => '',
		'meta_key'               => '',
		'meta_value'             => '',
		'meta_type'              => '',
		'meta_compare'           => '',
	);

	if ( ! empty( $query ) ) {
		$this->query( $query );
	}
}