It’s false that a plugin file is not required to be in the standard plugin folder. This plugin folder is defined by the constant WP_PLUGIN_DIR
, whose value is WP_CONTENT_DIR . '/plugins'
.
And if you open /wp-includes/load.php
, you will find that function wp_get_active_and_valid_plugins()
, defined by
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 . "https://wordpress.stackexchange.com/" . $plugin ) // $plugin must exist
// not already included as a network plugin
&& ( ! $network_plugins || ! in_array( WP_PLUGIN_DIR . "https://wordpress.stackexchange.com/" . $plugin, $network_plugins ) )
)
$plugins[] = WP_PLUGIN_DIR . "https://wordpress.stackexchange.com/" . $plugin;
}
return $plugins;
}
retrieves an array of valid and active plugins from the default directory defined by WP_PLUGIN_DIR.