wp_get_active_network_plugins

函式
wp_get_active_network_plugins ( No parameters )
Access
Private
返回值
  • (string[]) Array of absolute paths to files to include.
定義位置
相關方法
wp_get_active_and_valid_pluginswp_update_network_countsget_main_network_idwp_get_mu_pluginswp_get_network
引入
3.1.0
棄用
-

wp_get_active_network_plugins: 這個函式返回一個WordPress多站點網路的活動外掛陣列。

返回要包含在全域性範圍內的網路外掛檔案陣列。

預設目錄是wp-content/plugins。要手動改變預設目錄,在`wp-config.php`中定義`WP_PLUGIN_DIR`和`WP_PLUGIN_URL`。

function wp_get_active_network_plugins() {
	$active_plugins = (array) get_site_option( 'active_sitewide_plugins', array() );
	if ( empty( $active_plugins ) ) {
		return array();
	}

	$plugins        = array();
	$active_plugins = array_keys( $active_plugins );
	sort( $active_plugins );

	foreach ( $active_plugins as $plugin ) {
		if ( ! validate_file( $plugin )                     // $plugin must validate as file.
			&& '.php' === substr( $plugin, -4 )             // $plugin must end with '.php'.
			&& file_exists( WP_PLUGIN_DIR . '/' . $plugin ) // $plugin must exist.
			) {
			$plugins[] = WP_PLUGIN_DIR . '/' . $plugin;
		}
	}

	return $plugins;
}

常見問題

FAQs
檢視更多 >