Closed swissspidy closed 7 years ago
Interesting.
I'd be more inclined to call this a bug in WordPress. Plugin folders shouldn't legitimately contain more than 1 header, and it should probably stop once it's found one. That way packages like this are possible, and drop-ins -- which support plugin headers -- can continue to have them.
I wonder if it's actually allowed/supported for a plugin's directory to have multiple. Hmm.
It's possible to have multiple plugin files in one folder, WordPress allows it. In the early days Jetpack "bundled" a few plugins, for example. I thought it's not allowed in the repository, but your plugin seems to prove me wrong.
Of course it's a bad practice, but, you know, back compat.
It's pretty weird. Normally, plugins in the same folder are all displayed in the plugin list table, here that doesn't seem to be the case. So it might indeed be a bug in WordPress. That would explain the behaviour (not working after install but working in the plugin list table).
I hope I'll find time to test this more…
@swissspidy can you confirm if this is still an issue with drop-ins being nested a second directory deep?
Can't really test since it's not yet on WordPress.org, but I had another look at core. The relevant code in wp_ajax_install_plugin()
is as follows:
$api = plugins_api( 'plugin_information', array(
'slug' => sanitize_key( wp_unslash( $_POST['slug'] ) ),
'fields' => array(
'sections' => false,
),
) );
$install_status = install_plugin_install_status( $api );
$status['activateUrl'] = add_query_arg( array(
'_wpnonce' => wp_create_nonce( 'activate-plugin_' . $install_status['file'] ),
'action' => 'activate',
'plugin' => $install_status['file'],
), network_admin_url( 'plugins.php' ) );
In install_plugin_install_status()
:
$installed_plugin = get_plugins('/' . $api->slug);
$key = array_keys( $installed_plugin );
$key = reset( $key ); // Use the first plugin regardless of the name, Could have issues for multiple-plugins in one directory if they share different version numbers
There it is!
Please consider keeping a line comment: Spider-Cache advanced cache drop-in
Can't seem to reproduce this anymore when "shiny" installing & activating WP Spider Cache. 🤷♂️
When installing the plugin from WordPress.org, WordPress wrongly detects the drop-ins as the main plugin files because they contain a valid plugin header. That means the plugin can't be activated right away after installing.
On the "Installed Plugins" screen, it works as expected.