返回要包含在全局范围内的网络插件文件的数组。
原型
wp_get_active_network_plugins()
描述
默认目录是wp-content / plugins。要手动更改默认目录,请在wp-config.php中定义WP_PLUGIN_DIR和WP_PLUGIN_URL。
返回值
(array)
要包含的文件。
源文件
路径:wp-includes/ms-load.php
<?php
...
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;
}
...
?>
其他
英文文档:https://developer.wordpress.org/reference/functions/wp_get_active_network_plugins/