插件文件不需要位于标准插件文件夹中,这是错误的。此插件文件夹由常量定义WP_PLUGIN_DIR
, 其值为WP_CONTENT_DIR . \'/plugins\'
.如果你打开/wp-includes/load.php
, 您将找到该函数wp_get_active_and_valid_plugins()
, 定义人
function wp_get_active_and_valid_plugins() {
$plugins = array();
$active_plugins = (array) get_option( \'active_plugins\', array() );
// Check for hacks file if the option is enabled
if ( get_option( \'hack_file\' ) && file_exists( ABSPATH . \'my-hacks.php\' ) ) {
_deprecated_file( \'my-hacks.php\', \'1.5\' );
array_unshift( $plugins, ABSPATH . \'my-hacks.php\' );
}
if ( empty( $active_plugins ) || defined( \'WP_INSTALLING\' ) )
return $plugins;
$network_plugins = is_multisite() ? wp_get_active_network_plugins() : false;
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
// not already included as a network plugin
&& ( ! $network_plugins || ! in_array( WP_PLUGIN_DIR . \'/\' . $plugin, $network_plugins ) )
)
$plugins[] = WP_PLUGIN_DIR . \'/\' . $plugin;
}
return $plugins;
}
从WP\\u PLUGIN\\u DIR定义的默认目录中检索有效和活动插件的数组。