Skip to content

Connection: register WP Abilities API reads#48735

Draft
enejb wants to merge 1 commit into
trunkfrom
add/ship-connection-abilities
Draft

Connection: register WP Abilities API reads#48735
enejb wants to merge 1 commit into
trunkfrom
add/ship-connection-abilities

Conversation

@enejb
Copy link
Copy Markdown
Member

@enejb enejb commented May 12, 2026

Summary

Adds two read-only abilities to the automattic/jetpack-connection package so AI agents can inspect site- and user-level Jetpack connection state through the standard wp-abilities/v1 REST surface.

Slugs registered:

  • jetpack-connection/get-connection-status — site-level state as { site_connected, user_connected, master_user, plan_class, blog_id, registration_url, jetpack_version }. Zero-arg. Read-only. Idempotent.
  • jetpack-connection/get-current-user-connection — calling user's state as { id, login, connected, is_master_user, connect_url }. Returns WP_Error (jetpack_connection_not_logged_in) for anonymous callers. Read-only. Idempotent.

Both abilities extend Automattic\Jetpack\WP_Abilities\Registrar, are gated behind the package-wide jetpack_wp_abilities_enabled filter (default false), and use Manager::is_connected() / Manager::has_connected_user() / Manager::is_user_connected() rather than raw option reads.

Writes (registering / disconnecting / transferring ownership) are deliberately deferred to a follow-up PR.

Cross-consumer wiring

The Connection package is consumed by every Jetpack-family plugin (jetpack, boost, social, search, protect, backup, etc.), so registration is wired from projects/packages/connection/actions.php at plugins_loaded priority 20. As soon as a site opts in to abilities via the jetpack_wp_abilities_enabled filter, every connection-consuming plugin will see these two slugs without each one needing its own wiring.

Rollout plan reference

Maps to §4.2 (package-backed abilities live in their package) and §4.5 (cross-consumer wiring via actions.php) of the Abilities Everywhere rollout plan.

Test plan

  • composer phpunit -- --filter Connection_Abilities_Test passes locally (16 tests, 69 assertions).
  • Test coverage: Registrar wiring (gate off / gate on / category auto-injection / per-ability should_register filter), abstract getters (slug / definition / specs), permission callbacks (anonymous denied / authenticated allowed), execute happy paths for both abilities (with Connection_Manager stub injected via a new jetpack_connection_abilities_manager filter), and the anonymous WP_Error path for get-current-user-connection.
  • phpcs clean on the new/changed files using the repo .phpcs.xml.dist ruleset.
  • changelogger validate exits 0; changelog entry added at projects/packages/connection/changelog/add-connection-abilities (type added, significance minor).
  • On a running WP site with add_filter( 'jetpack_wp_abilities_enabled', '__return_true' ), confirm both slugs show up via wp_get_abilities() and /wp-json/wp-abilities/v1/abilities.
  • Verify the abilities also register when the consumer is a non-Jetpack plugin (e.g. Jetpack Boost alone, without the Jetpack plugin loaded).

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 12, 2026

Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.

  • To test on WoA, go to the Plugins menu on a WoA dev site. Click on the "Upload" button and follow the upgrade flow to be able to upload, install, and activate the Jetpack Beta plugin. Once the plugin is active, go to Jetpack > Jetpack Beta, select your plugin (Jetpack or WordPress.com Site Helper), and enable the add/ship-connection-abilities branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack add/ship-connection-abilities
bin/jetpack-downloader test jetpack-mu-wpcom-plugin add/ship-connection-abilities

Interested in more tips and information?

  • In your local development environment, use the jetpack rsync command to sync your changes to a WoA dev blog.
  • Read more about our development workflow here: PCYsg-eg0-p2
  • Figure out when your changes will be shipped to customers here: PCYsg-eg5-p2

@github-actions
Copy link
Copy Markdown
Contributor

Thank you for your PR!

When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:

  • ✅ Include a description of your PR changes.
  • 🔴 Add a "[Status]" label (In Progress, Needs Review, ...).
  • 🔴 Add testing instructions.
  • 🔴 Specify whether this PR includes any changes to data or privacy.
  • ✅ Add changelog entries to affected projects

This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖


🔴 Action required: Please include detailed testing steps, explaining how to test your change, like so:

## Testing instructions:

* Go to '..'
*

🔴 Action required: We would recommend that you add a section to the PR description to specify whether this PR includes any changes to data or privacy, like so:

## Does this pull request change what data or activity we track or use?

My PR adds *x* and *y*.

Follow this PR Review Process:

  1. Ensure all required checks appearing at the bottom of this PR are passing.
  2. Make sure to test your changes on all platforms that it applies to. You're responsible for the quality of the code you ship.
  3. You can use GitHub's Reviewers functionality to request a review.
  4. When it's reviewed and merged, you will be pinged in Slack to deploy the changes to WordPress.com simple once the build is done.

If you have questions about anything, reach out in #jetpack-developers for guidance!

@github-actions github-actions Bot added the [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. label May 12, 2026
@jp-launch-control
Copy link
Copy Markdown

Code Coverage Summary

1 file is newly checked for coverage.

File Coverage
projects/packages/connection/src/abilities/class-connection-abilities.php 125/129 (96.90%) 💚

Full summary · PHP report · JS report

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

Labels

[Package] Connection [Status] In Progress [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. [Tests] Includes Tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant