is_plugin_active_for_network

函式
is_plugin_active_for_network ( $plugin )
引數
  • (string) $plugin Path to the plugin file relative to the plugins directory.
    Required:
返回值
  • (bool) True if active for the network, otherwise false.
定義位置
相關方法
is_plugin_activeis_plugin_inactivewp_get_active_network_pluginswp_is_large_networkis_main_network
引入
3.0.0
棄用
-

is_plugin_active_for_network: 這個函式檢查一個特定的外掛是否在整個WordPress多站點網路中處於活動狀態。它把外掛的名字作為一個引數,如果該外掛是活動的,則返回true,如果不是,則返回false。

確定該外掛是否對整個網路處於啟用狀態。

只有安裝在plugins/資料夾中的外掛才是活躍的。

mu-plugins/資料夾中的外掛不能被””啟用,””所以這個函式對這些外掛將返回false。

關於這個和類似的主題函式的更多資訊,請檢視《主題開發者手冊》中的{@link Conditional Tags}文章。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
function is_plugin_active_for_network( $plugin ) {
if ( ! is_multisite() ) {
return false;
}
$plugins = get_site_option( 'active_sitewide_plugins' );
if ( isset( $plugins[ $plugin ] ) ) {
return true;
}
return false;
}
function is_plugin_active_for_network( $plugin ) { if ( ! is_multisite() ) { return false; } $plugins = get_site_option( 'active_sitewide_plugins' ); if ( isset( $plugins[ $plugin ] ) ) { return true; } return false; }
function is_plugin_active_for_network( $plugin ) {
	if ( ! is_multisite() ) {
		return false;
	}

	$plugins = get_site_option( 'active_sitewide_plugins' );
	if ( isset( $plugins[ $plugin ] ) ) {
		return true;
	}

	return false;
}

常見問題

FAQs
檢視更多 >