After installing a plugin via the "Add New" screen, the "Install Now" button changes to "Installed" then "Activate".
This PR checks whether the plugin has any inactive dependencies. If so, the "Install Now" button changes to "Installed" then "Cannot Activate".
For the feature plugin, a custom script is used which overwrites wp.updates.installPluginSuccess(). For a Core merge, the changes can be made directly in Core's src/wp-admin/js/updates.js, and the admin_enqueue_scripts hook can be removed in WP_Plugin_Dependencies::start().
Steps To Test
Open DevTools on the Network tab.
Scenario 1: A plugin with no dependencies
From Plugins > Add New, install a plugin with no dependencies.
Expected results:
The button should read "Activate".
The admin-ajax.php response should indicate success.
A data: { slug, message } entry should indicate that the plugin has no required plugins.
Scenario 2: A plugin with no active dependencies
From Plugins > Add New, install a plugin with two dependencies (try searching sso metadata, for example).
From the plugin card, click "View details" on both dependencies and install them.
Wait about 10-30 seconds, then refresh the page. (I know. This is the next bit we need to handle.).
Now click "Install Now" on the dependent plugin.
Expected results:
The button should read "Cannot Activate".
The admin-ajax.php response should indicate failure.
A data: { slug, errorCode, errorMessage, errorData } entry should mention that both dependencies must be activated first.
Scenario 3: A plugin with one active dependency
Delete the dependent plugin, but keep the dependencies.
Navigate to Plugins > Installed plugins and activate one of the dependencies.
Navigate back to the "Add New" screen.
Click "Install Now" on the dependent plugin.
Expected results:
The button should read "Cannot Activate".
The admin-ajax.php response should indicate failure.
A data: { slug, errorCode, errorMessage, errorData } entry should mention only the inactive dependency must be activated first.
Scenario 4: A plugin with all its dependencies active
Delete the dependent plugin, but keep the dependencies.
Navigate to Plugins > Installed plugins and activate the remaining dependency.
Navigate back to the "Add New" screen.
Click "Install Now" on the dependent plugin.
Expected results:
The button should read "Activate".
The admin-ajax.php response should indicate success.
A data: { slug, message } entry should indicate all required plugins are installed and activated.
After installing a plugin via the "Add New" screen, the "Install Now" button changes to "Installed" then "Activate".
This PR checks whether the plugin has any inactive dependencies. If so, the "Install Now" button changes to "Installed" then "Cannot Activate".
For the feature plugin, a custom script is used which overwrites
wp.updates.installPluginSuccess()
. For a Core merge, the changes can be made directly in Core'ssrc/wp-admin/js/updates.js
, and theadmin_enqueue_scripts
hook can be removed inWP_Plugin_Dependencies::start()
.Steps To Test
Open DevTools on the
Network
tab.Scenario 1: A plugin with no dependencies
Plugins > Add New
, install a plugin with no dependencies.Expected results:
admin-ajax.php
response should indicate success.data: { slug, message }
entry should indicate that the plugin has no required plugins.Scenario 2: A plugin with no active dependencies
Plugins > Add New
, install a plugin with two dependencies (try searchingsso metadata
, for example).Expected results:
admin-ajax.php
response should indicate failure.data: { slug, errorCode, errorMessage, errorData }
entry should mention that both dependencies must be activated first.Scenario 3: A plugin with one active dependency
Plugins > Installed plugins
and activate one of the dependencies.Expected results:
admin-ajax.php
response should indicate failure.data: { slug, errorCode, errorMessage, errorData }
entry should mention only the inactive dependency must be activated first.Scenario 4: A plugin with all its dependencies active
Plugins > Installed plugins
and activate the remaining dependency.Expected results:
admin-ajax.php
response should indicate success.data: { slug, message }
entry should indicate all required plugins are installed and activated.