is_plugin_active

函式
is_plugin_active ( $plugin )
引數
  • (string) $plugin Path to the plugin file relative to the plugins directory.
    Required:
返回值
  • (bool) True, if in the active plugins list. False, not in the list.
定義位置
相關方法
is_plugin_inactiveis_plugin_pageis_plugin_pausedlist_plugin_updatesis_plugin_active_for_network
引入
2.5.0
棄用
-

is_plugin_active: 這個函式檢查一個特定的外掛是否處於活動狀態。它將外掛名稱作為引數,如果該外掛處於活動狀態,則返回 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( $plugin ) {
return in_array( $plugin, (array) get_option( 'active_plugins', array() ), true ) || is_plugin_active_for_network( $plugin );
}
function is_plugin_active( $plugin ) { return in_array( $plugin, (array) get_option( 'active_plugins', array() ), true ) || is_plugin_active_for_network( $plugin ); }
function is_plugin_active( $plugin ) {
	return in_array( $plugin, (array) get_option( 'active_plugins', array() ), true ) || is_plugin_active_for_network( $plugin );
}

常見問題

FAQs
檢視更多 >