Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 1, 2025

Plugin Dependencies Support Implementation - COMPLETE ✅

This PR successfully implements plugin dependencies support for WordPress 6.5+ as requested in the issue.

Features Implemented

  1. --with-dependencies flag for plugin install

    • Automatically installs all required dependencies when installing a plugin
    • Recursively resolves dependency chains
    • Handles circular dependencies and already-processed plugins
    • Works with WordPress.org plugins (fetches dependencies via API)
    • Gracefully handles local zip files and URLs (skips dependency resolution)
  2. plugin install-dependencies command

    • Installs all dependencies of an already installed plugin
    • Useful when you have a plugin installed but need to install its dependencies
    • Supports --activate and --activate-network flags for dependencies
    • Reads dependencies from the plugin's Requires Plugins header
  3. Dependencies display in plugin get

    • Already supported via the requires_plugins field
    • Shows comma-separated list of required plugin slugs

Implementation Details

  • Minimal changes: Only modified necessary files (Plugin_Command.php, composer.json)
  • Uses WP_Plugin_Dependencies class: Leverages WordPress 6.5+ native class for dependency management
  • API integration: Falls back to plugins_api() for plugins not yet installed
  • Error handling: Warnings for API failures, graceful fallbacks
  • Recursive resolution: Dependencies are installed in correct order (dependencies first)
  • Duplicate prevention: Tracks processed plugins to avoid redundant installations
  • PHP compatibility: Uses PHP 5.6+ compatible code (strpos, not str_contains)
  • Code style: Fixed PHPCS alignment issues

Testing

  • Added comprehensive Behat test scenarios in features/plugin-dependencies.feature
  • Tests cover: basic installation, activation, no dependencies, error cases
  • All scenarios tagged with @require-wp-6.5 for WordPress version compatibility
  • Fixed test assertions to check correct plugin names

Code Quality

  • ✅ PHP syntax validated
  • ✅ composer.json validated
  • ✅ Code review feedback addressed
  • ✅ PHPCS formatting issues fixed
  • ✅ Uses WP_Plugin_Dependencies class as requested
  • ✅ Documentation examples updated to match actual output
  • ✅ Test assertions corrected
  • ✅ No security vulnerabilities (CodeQL clean)
  • ✅ Follows existing code patterns and conventions

Files Changed

  • src/Plugin_Command.php: +163 lines (main implementation)
  • composer.json: +1 line (register new command)
  • features/plugin-dependencies.feature: +131 lines (tests)
  • Total: 295 lines added, 1 line removed

All requirements from the original issue have been fully implemented and tested.

Original prompt

This section details on the original issue you should resolve

<issue_title>Plugin Dependencies Support</issue_title>
<issue_description>## Feature Request

WordPress 6.5 adds the Plugin Dependencies capability. It would be useful if plugin install had a --with-dependencies flag to also install the dependencies of the plugin being installed.
</issue_description>

Comments on the Issue (you are @copilot in this section)

@swissspidy Generally speaking, we need to test with the new plugin dependencies feature and see if and what to change. If the plugin‘s API provides this information easily, then I could see such a flag being useful for sure. @swissspidy Right. This is surfaced in the API via the `requires_plugins` field which contains an array of slugs.

Example: https://api.wordpress.org/plugins/info/1.2/?action=plugin_information&request%5Blocale%5D=en_US&request%5Bslug%5D=wpsso-wc-metadata&fields=versions

So should be available for us too 👍

Edit:

for already installed plugins we might be able to use the WP_Plugin_Dependencies class</comment_new>
<comment_new>@swissspidy
One use case I just stumbled upon:

Provide an easy way to install all dependencies of a plugin.

e.g. if I have plugin X installed (not necessarily activated) that depends on Y and Z, I want an easy way to install Y and Z, without having to activate X.</comment_new>
<comment_new>@swissspidy
Listing dependencies in wp plugin get <slug> would also be useful</comment_new>


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI changed the title [WIP] Add support for plugin dependencies in install command Add plugin dependencies support with --with-dependencies flag and install-dependencies command Nov 1, 2025
Copilot AI requested a review from swissspidy November 1, 2025 20:35
@swissspidy

This comment was marked as resolved.

This comment was marked as resolved.

@swissspidy

This comment was marked as resolved.

This comment was marked as resolved.

@swissspidy swissspidy marked this pull request as ready for review November 2, 2025 10:37
@swissspidy swissspidy requested a review from a team as a code owner November 2, 2025 10:37
@codecov
Copy link

codecov bot commented Nov 2, 2025

Codecov Report

❌ Patch coverage is 81.35593% with 11 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/Plugin_Command.php 81.35% 11 Missing ⚠️

📢 Thoughts on this report? Let us know!

@swissspidy swissspidy added this to the 2.3.0 milestone Nov 11, 2025
@swissspidy swissspidy added command:plugin Related to 'plugin' command command:plugin-install Related to 'plugin install' command labels Dec 12, 2025
@swissspidy swissspidy requested a review from Copilot December 19, 2025 09:33
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR implements comprehensive plugin dependencies support for WordPress 6.5+ by adding the --with-dependencies flag to the plugin install command and a new plugin install-dependencies subcommand.

Key Changes

  • Added --with-dependencies flag that recursively resolves and installs plugin dependencies from the WordPress.org API or installed plugin headers
  • Implemented plugin install-dependencies command to install dependencies of already-installed plugins without activating the main plugin
  • Added comprehensive Behat test scenarios covering various dependency installation workflows

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 6 comments.

File Description
src/Plugin_Command.php Core implementation: adds dependency resolution logic, recursive collection, and WordPress 6.5+ version checks
composer.json Registers the new plugin install-dependencies subcommand
features/plugin-dependencies.feature Comprehensive test scenarios for both new features with WordPress version compatibility tags

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

command:plugin Related to 'plugin' command command:plugin-install Related to 'plugin install' command

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Plugin Dependencies Support

2 participants