Publicize: register WP Abilities API surface#48739
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
Registers the first Jetpack Publicize abilities so agents can manage Social via the
wp-abilities/v1REST surface. Gated behind thejetpack_wp_abilities_enabledfilter (default false), so this is a no-op until a site opts in.Three abilities ship in this PR:
jetpack-publicize/list-connections— read-only, idempotent. Returns the site's connected social accounts as{ id, service, external_id, external_name, external_display_name, external_handle, profile_link, profile_picture, status, shared }.jetpack-publicize/get-share-status— read-only, idempotent. Returns the share-status snapshot for a published post:{ post_id, can_be_shared, done, shares, scheduled_shares }. Mirrors thewpcom/v2/publicize/share-statusREST contract.jetpack-publicize/delete-connection— destructive but idempotent write. Disconnects a single social account; deleting an already-gone connection returnschanged=false. Mirrors the REST controller's delete path.set-message,schedule-share, andupdate-share-messageare intentionally deferred to a follow-up PR.Wiring
Publicize_Abilities::init()fires fromPublicize_Setup::pre_initialization()(the publicize package's autoloaded bootstrap). Because the Social plugin and the Jetpack plugin (publicize module) both load this package and callpre_initialization()via the Config package, the abilities surface activates in both consumers automatically — noactions.phpchanges needed. See plan §4.2 / §4.5.Permissions
list-connections,get-share-status):publish_posts. Mirrors the RESTpublicize_permissions_checkintent.delete-connection):edit_others_posts. MirrorsConnections_Controller::manage_connection_permission_check's editor+ default. Owner-only deletes aren't exposed at the abilities surface — gating an arbitrary id by ownership before the permission check leaks existence of unowned connections.Test plan
composer phpunit -- --filter Publicize_Abilities_Test(36/36 pass, 122 assertions).composer phpunitfor the full publicize package (114 pass, 4 pre-existing skips).composer phpcs:linton new files clean.add_filter( 'jetpack_wp_abilities_enabled', '__return_true' ), confirmwp_get_abilities()lists the three slugs and/wp-json/wp-abilities/v1/abilitiesexposes them.