Image CDN abilities: register status reads via Registrar#48758
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 SummaryCoverage changed in 1 file.
1 file is newly checked for coverage.
|
Summary
Adds a minimal Abilities API surface to the
jetpack-image-cdnpackage via the sharedRegistrarbase class. Exposes a single read-only ability —jetpack-image-cdn/get-status— that returns the current Image CDN (Photon) activation state, effective CDN domain, srcset wiring flag, and the deduplicated list of supported MIME types.Per RSM "Abilities Everywhere" plan §4.2, this package is consumed by both Jetpack's Photon module and Boost, so wiring lives in the package's
actions.php(canonical guarded pattern fromprojects/packages/publicize/actions.php). Registration is gated behind thejetpack_wp_abilities_enabledfilter (default false) insideRegistrar::init()— no behavior change until the filter is opted in.get-statisticsfrom the original plan was dropped because the package tracks no local statistics — the audit found no bytes-saved, request-count, or last-request timestamp surface.update-settingsandclear-cachewrites are intentionally deferred; this PR is reads-only.Surface
jetpack-image-cdn/get-status—{ active, settings: { quality, formats, srcset_enabled, cdn_domain }, supported_mime_types: [string] }.qualityandformatsarenullbecause the consumer plugin (not this package) owns those toggles.Permissions
current_user_can( 'manage_options' )— the package has no domain-specific capability of its own; reuse the site-admin cap.Test plan
composer phpunit -- --filter Image_CDN_Abilities_Test(21 tests, 62 assertions, all green)add_filter( 'jetpack_wp_abilities_enabled', '__return_true' )on a site running this branch with the Image CDN module active; confirmwp_get_abilities()includesjetpack-image-cdn/get-statusand that/wp-json/wp-abilities/v1/abilitiesexposes it.wp_get_abilities().jetpack_photon_domainwith a custom host; confirm the returnedsettings.cdn_domainreflects it.Image_CDN_Core_Test::test_photon_url_filter_url_encodes_path_partsis unrelated to this change).