函数原型
get_network( WP_Network|int|null $network = null ): WP_Network|null
函数描述
Retrieves network data given a network ID or network object.
是否弃用
未弃用
函数参数
-
$network
WP_Network|int|null
Optional - Network to retrieve. Default is the current network.
Default:
null
函数返回值
WP_Network|null The network object or null if not found.
函数位置
File: wp-includes/ms-network.php.
函数源码
function get_network( $network = null ) {
global $current_site;
if ( empty( $network ) && isset( $current_site ) ) {
$network = $current_site;
}
if ( $network instanceof WP_Network ) {
$_network = $network;
} elseif ( is_object( $network ) ) {
$_network = new WP_Network( $network );
} else {
$_network = WP_Network::get_instance( $network );
}
if ( ! $_network ) {
return null;
}
/**
* Fires after a network is retrieved.
*
* @since 4.6.0
*
* @param WP_Network $_network Network data.
*/
$_network = apply_filters( 'get_network', $_network );
return $_network;
}
源码链接
变更日志
| Version | Description |
|---|---|
| 4.6.0 | Introduced. |

