wp_count_sites
函数
wp_count_sites ( $network_id = null )
- 参数
-
-
(int)
$network_id
Optional. The network to get counts for. Default is the current network ID.- Required: 否
- Default: null
-
(int)
- 返回值
-
- (int[]) { Numbers of sites grouped by site status. @type int $all The total number of sites. @type int $public The number of public sites. @type int $archived The number of archived sites. @type int $mature The number of mature sites. @type int $spam The number of spam sites. @type int $deleted The number of deleted sites. }
- 定义位置
-
-
wp-includes/ms-blogs.php
, line 936
-
wp-includes/ms-blogs.php
- 引入
- 5.3.0
- 弃用
- –
Count number of sites grouped by site status.
function wp_count_sites( $network_id = null ) { if ( empty( $network_id ) ) { $network_id = get_current_network_id(); } $counts = array(); $args = array( 'network_id' => $network_id, 'number' => 1, 'fields' => 'ids', 'no_found_rows' => false, ); $q = new WP_Site_Query( $args ); $counts['all'] = $q->found_sites; $_args = $args; $statuses = array( 'public', 'archived', 'mature', 'spam', 'deleted' ); foreach ( $statuses as $status ) { $_args = $args; $_args[ $status ] = 1; $q = new WP_Site_Query( $_args ); $counts[ $status ] = $q->found_sites; } return $counts; }
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。