Skip to content

Conversation

@justlevine
Copy link
Contributor

What

This PR polishes up #35 , making it usable as both a WordPress plugin and a Composer library.

How

  1. Library type switched back to wordpress-plugin, allowing for plugin installation using composer.json:extra.
  2. Removed the composer.json:autoload prop in favor of manually require_once, depending on if the user wants the REST API endpoints (and the rest of the plugin) or just the API classes and functions.
  3. Restored the WP_ABILITIES_API_VERSION const for version targeting, moved into bootstrap.php
  4. Added usage docs for both plugin and dependency, composer and non-composer usage.

More specific comments inline.

Additional notes

I'm not entirely sure the use case of wanting to require_once the classes but not hook the REST API endpoints. Without it, we dont need a separate "library vs plugin" bootstrap, devs can can just require_once the same root abilities-api.php as WordPress core would do if it was located in wp-content/plugins instead of my-plugin/vendor/*.

Left it in this PR to respect the Chesterton fence (though I'm like 95% sure it's just an artifact of from the prior art and not relevant here).

@justlevine justlevine requested a review from Copilot August 22, 2025 15:04
Copy link
Contributor

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 polishes the Abilities API to function as both a WordPress plugin and a Composer library, providing flexible installation and usage options. The changes allow developers to either install the complete plugin with REST API endpoints or include just the core classes as a dependency.

  • Switched composer type back to wordpress-plugin to enable plugin installation via Composer
  • Removed autoload configuration in favor of manual require_once for better control over loading
  • Added comprehensive installation and usage documentation covering multiple scenarios

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
composer.json Changed type to wordpress-plugin and removed autoload configuration
includes/bootstrap.php Added version constant and updated documentation for library usage
docs/2.getting-started.md Added comprehensive installation guides for plugin and dependency usage
abilities-api.php Minor formatting cleanup (removed extra blank line)

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@codecov
Copy link

codecov bot commented Aug 22, 2025

Codecov Report

❌ Patch coverage is 0% with 13 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (update/composer-configuration@8a58d04). Learn more about missing BASE report.

Files with missing lines Patch % Lines
includes/bootstrap.php 0.00% 10 Missing ⚠️
abilities-api.php 0.00% 3 Missing ⚠️
Additional details and impacted files
@@                       Coverage Diff                        @@
##             update/composer-configuration      #42   +/-   ##
================================================================
  Coverage                                 ?   91.61%           
  Complexity                               ?       93           
================================================================
  Files                                    ?        8           
  Lines                                    ?      513           
  Branches                                 ?        0           
================================================================
  Hits                                     ?      470           
  Misses                                   ?       43           
  Partials                                 ?        0           
Flag Coverage Δ
unit 91.61% <0.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

# 2. Getting Started

## Installation Options
## Installation
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Personally I'd make this a separate INSTALLATION.md doc, but because the doc-files are # prefixed, I didnt want to blow up the diff here.

Copy link
Member

Choose a reason for hiding this comment

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

We can update that part after the package is available on Packagist.


### As a plugin

The best and easiest way to try and use the Abilities API is to install it as a plugin by downloading the latest release from the [GitHub Releases page](https://github.com/WordPress/abilities-api/releases/latest).
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This requires us to cut a release (but so does composer). Can use the path to trunk in the interim, I just didn't want to rewrite something that's anyway needs to be rewritten by a competent docs writer


Plugin authors and developers may wish to rely on the Abilities API as a dependency in their own projects, before it is merged into core. You can do that in one of the following ways.

#### As a Plugin Dependency (Recommended)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Even without it being on .org (and therefore available to autoinstall), I believe this should still be Recommended , since we want to ensure people are testing with the latest versions for the next few months, and not some potentially-deconflicted library.

But if you disagree, drop it.

Comment on lines +87 to +101

Until the plugin is available on Packagist, you will need to add the repository to your `composer.json` file.

```jsonc
{
"repositories": [
{
"type": "vcs",
"url": "https://github.com/WordPress/abilities-api.git"
}
// ... other repositories.
],
// ... rest of your composer.json.
}
```
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed once we're on packagist.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Mainly just cleaning up the composer specific comments.

* Useful to confirm you're using the latest version of the Abilities API.
*/
if ( ! defined( 'WP_ABILITIES_API_VERSION' ) ) {
define( 'WP_ABILITIES_API_VERSION', '0.1.0' );
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure if this was intentionally removed, but we need it for MCP Adapter / Experiments for the next 3 months if we want to be able to allow this library to evolve.

"installer-paths": {
// This should match your WordPress+Composer setup.
"wp-content/plugins/{$name}/": [
"type:wordpress-plugin"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is what we lose by making type: library instead of wordpress-plugin. We gain nothing.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@justlevine justlevine marked this pull request as ready for review August 22, 2025 15:24
@justlevine justlevine requested a review from gziolo August 22, 2025 15:35
Copy link
Contributor Author

@justlevine justlevine Aug 22, 2025

Choose a reason for hiding this comment

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

NOTE: This is only here for reviewers because there seems to be some confusion about WordPress Plugins and composer usage (also in MCP Adapter... ) so I wanted clear illustration I could point to. Would recommend @jonathanbossenger or someone else better than I to review before final merge.

@gziolo gziolo added the [Tool] Issues related to development tooling, such as linting, testing, or CI label Aug 26, 2025
@gziolo gziolo requested review from emdashcodes, gziolo and jonathanbossenger and removed request for gziolo August 27, 2025 05:45
@gziolo gziolo force-pushed the update/composer-configuration branch from 20d46e2 to 0cad3fe Compare August 28, 2025 07:18
@gziolo gziolo deleted the branch WordPress:update/composer-configuration August 28, 2025 12:34
@gziolo gziolo closed this Aug 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Tool] Issues related to development tooling, such as linting, testing, or CI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants