Licensing abilities: register list, error info, attach via Registrar#48755
Licensing abilities: register list, error info, attach via Registrar#48755enejb wants to merge 1 commit into
Conversation
|
Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.
Interested in more tips and information?
|
|
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
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: 🔴 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: Follow this PR Review Process:
If you have questions about anything, reach out in #jetpack-developers for guidance! |
Code Coverage Summary1 file is newly checked for coverage.
|
Summary
Ships three Jetpack Licensing abilities through the WordPress Abilities API (per RSM Abilities Everywhere plan §4.2):
jetpack-licensing/list-licenses— Filtered read overLicensing::get_user_licenses()withstatus(active|expired|attached|detached),license_id, and pagination. Returns a uniform{ id, slug, product_name, attached_at, status, expires_at }array.jetpack-licensing/get-error-info— Reads the latest license-attach error stored by the Licensing package (Licensing::last_error). Read-only.jetpack-licensing/attach-license— WrapsLicensing::attach_licenses(). Idempotent: re-attaching an already-attached key returnsattached=true. On failure returns{ attached: false, error: { code, message } }with the upstream code mapped to thejetpack_licensing_*vocabulary.Wiring is done via
projects/packages/licensing/actions.php(canonical guarded pattern matching publicize / connection). Registration is gated byjetpack_wp_abilities_enabled(default false) through theRegistrarbase class.Permissions reuse the existing
Endpoints::can_manage_options_checkgate (current_user_can( 'manage_options' )) so the abilities don't drift from the REST surface they wrap.Test plan
cd projects/packages/licensing && composer phpunit -- --filter Licensing_Abilities_Test— 30 tests, 127 assertions, all green.composer phpunit) — 46 tests, 188 assertions, all green.pnpm php:lintclean on new files.jetpack_wp_abilities_enabledfilter set true on a Jetpack-connected site,wp_get_abilities()lists the three new slugs and/wp-json/wp-abilities/v1/abilitiesexposes them.