get_network

函式
get_network ( $network = null )
引數
  • (WP_Network|int|null) $network Optional. Network to retrieve. Default is the current network.
    Required:
    Default: null
返回值
  • (WP_Network|null) The network object or null if not found.
定義位置
相關方法
get_networkswp_get_networkupgrade_networkget_network_optionget_ancestors
引入
4.6.0
棄用
-

get_network函式是一個WordPress函式,用於檢索給定網路ID或當前網路的網路資料。它可以用來檢索網路資料,如網路名稱、網路管理員電子郵件和網路域名。

給定一個網路ID或網路物件,檢索網路資料。

網路資料將被快取,並在通過一個過濾器後返回。如果提供的網路是空的,將使用當前的網路全域性。

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;
}

常見問題

FAQs
檢視更多 >