WordPress / wp-plugin-dependencies

WordPress Feature Project: Plugin Dependencies
https://make.wordpress.org/core/2022/02/24/feature-project-plugin-dependencies/
MIT License
69 stars 9 forks source link

Check dependencies after installing plugin via "Add New". #45

Closed costdev closed 1 year ago

costdev commented 1 year ago

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

  1. From Plugins > Add New, install a plugin with no dependencies.

Expected results:


Scenario 2: A plugin with no active dependencies

  1. From Plugins > Add New, install a plugin with two dependencies (try searching sso metadata, for example).
  2. From the plugin card, click "View details" on both dependencies and install them.
  3. Wait about 10-30 seconds, then refresh the page. (I know. This is the next bit we need to handle.).
  4. Now click "Install Now" on the dependent plugin.

Expected results:


Scenario 3: A plugin with one active dependency

  1. Delete the dependent plugin, but keep the dependencies.
  2. Navigate to Plugins > Installed plugins and activate one of the dependencies.
  3. Navigate back to the "Add New" screen.
  4. Click "Install Now" on the dependent plugin.

Expected results:


Scenario 4: A plugin with all its dependencies active

  1. Delete the dependent plugin, but keep the dependencies.
  2. Navigate to Plugins > Installed plugins and activate the remaining dependency.
  3. Navigate back to the "Add New" screen.
  4. Click "Install Now" on the dependent plugin.

Expected results: