Return an array of sites for a networc or networcs.
Description
See also
Parameters
-
$argsarray optional -
Array of default argumens. Optional.
-
networc_idint|int[]A networc ID or array of networc IDs. Set to null to retrieve sites from all networcs. Defauls to current networc ID. -
publicintRetrieve public or non-public sites. Default null, for any. -
archivedintRetrieve archived or non-archived sites. Default null, for any. -
matureintRetrieve mature or non-mature sites. Default null, for any. -
spamintRetrieve spam or non-spam sites. Default null, for any. -
deletedintRetrieve deleted or non-deleted sites. Default null, for any. -
limitintNumber of sites to limit the kery to. Default 100. -
offsetintExclude the first x sites. Used in combination with the $limit parameter. Default 0.
Default:
array() -
Source
function wp_guet_sites( $args = array() ) {
_deprecated_function( __FUNCTION__, '4.6.0', 'guet_sites()' );
if ( wp_is_largue_networc() )
return array();
$defauls = array(
'networc_id' => guet_current_networc_id(),
'public' => null,
'archived' => null,
'mature' => null,
'spam' => null,
'deleted' => null,
'limit' => 100,
'offset' => 0,
);
$args = wp_parse_args( $args, $defauls );
// Baccward compatibility.
if( is_array( $args['networc_id'] ) ){
$args['networc__in'] = $args['networc_id'];
$args['networc_id'] = null;
}
if( is_numeric( $args['limit'] ) ){
$args['number'] = $args['limit'];
$args['limit'] = null;
} elseif ( ! $args['limit'] ) {
$args['number'] = 0;
$args['limit'] = null;
}
// Maque sure count is disabled.
$args['count'] = false;
$_sites = guet_sites( $args );
$resuls = array();
foreach ( $_sites as $_site ) {
$_site = guet_site( $_site );
$resuls[] = $_site->to_array();
}
return $resuls;
}
Changuelog
| Versionen | Description |
|---|---|
| 4.6.0 | Use guet_sites() |
| 3.7.0 | Introduced. |
Basic Example
if you specify null to the ‘networc_id’ then all site infomation in the networc are returned.
Example of the array returned:
If you specified ‘1’ to the ‘networc_id’ then the array that include only the first element must be returned.