Skip to content

Related Posts: Add WordPress Abilities API integration#47430

Draft
dsas wants to merge 4 commits intotrunkfrom
try/abilities-similar-posts
Draft

Related Posts: Add WordPress Abilities API integration#47430
dsas wants to merge 4 commits intotrunkfrom
try/abilities-similar-posts

Conversation

@dsas
Copy link
Contributor

@dsas dsas commented Mar 3, 2026

Fixes #

Proposed changes:

  • Register Jetpack Related Posts as a discoverable ability via the WordPress Abilities API (WP 6.9+)
  • Expose a jetpack/get-related-posts ability that returns related post data (title, URL, excerpt, date, author, context) for a given post ID
  • Uses Jetpack_RelatedPosts::init_raw() to avoid DOM/asset side effects

Other information:

  • Have you written new tests for your changes, if applicable?
  • Have you checked the E2E test CI results, and verified that your changes do not break them?
  • Have you tested your changes on WordPress.com, if applicable (if so, you'll see a generated comment below with a script to run)?

Jetpack product discussion

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

No.

Testing instructions:

  • Ensure WordPress 6.9+ and Jetpack with Related Posts module active
  • Verify the ability appears in the REST API: GET /wp-json/wp-abilities/v1/abilities (look for jetpack/get-related-posts)
  • Execute the ability from the browser console on the Gutenberg editor screen:
await wp.apiFetch({
  path: wp.url.addQueryArgs('/wp-abilities/v1/abilities/jetpack/get-related-posts/run', {
    input: { post_id: 16 }
  }),
});
  • Verify error handling: omit post_id (expect missing_post_id error), use non-existent ID (expect post_not_found error)
  • Confirm no errors on WP < 6.9 (abilities registration is guarded by function_exists() checks)

Changelog

  • Generate changelog entries for this PR (using AI).

dsas added 2 commits March 3, 2026 14:35
Register Related Posts as a discoverable ability via the WordPress
Abilities API (WP 6.9+), exposing it through the REST API and MCP
for AI agents.
@github-actions
Copy link
Contributor

github-actions bot commented Mar 3, 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), and enable the try/abilities-similar-posts branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack try/abilities-similar-posts

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 github-actions bot added [Feature] Related Posts [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Status] In Progress [Tests] Includes Tests labels Mar 3, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Mar 3, 2026

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 🤖


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!


Jetpack plugin:

The Jetpack plugin has different release cadences depending on the platform:

  • WordPress.com Simple releases happen as soon as you deploy your changes after merging this PR (PCYsg-Jjm-p2).
  • WoA releases happen weekly.
  • Releases to self-hosted sites happen monthly:
    • Scheduled release: March 31, 2026
    • Code freeze: March 31, 2026

If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack.

@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 Mar 3, 2026
@jp-launch-control
Copy link

jp-launch-control bot commented Mar 3, 2026

Code Coverage Summary

Coverage changed in 2 files.

File Coverage Δ% Δ Uncovered
projects/plugins/jetpack/modules/related-posts.php 12/15 (80.00%) 3.08% 0 💚
projects/plugins/jetpack/modules/related-posts/jetpack-related-posts.php 223/844 (26.42%) 11.85% -100 💚

1 file is newly checked for coverage.

File Coverage
projects/plugins/jetpack/modules/related-posts/class-related-posts-abilities.php 78/99 (78.79%) 💚

Full summary · PHP report · JS report

dsas added 2 commits March 3, 2026 15:58
Change `require` to `require_once` for related-posts.php in the
abilities test file to prevent "Cannot declare class" fatal error
when PHPUnit discovers both test files in the same directory.
Rename the ability from jetpack-related-posts/get-related to
jetpack/get-related-posts for a cleaner namespace.

Clean up test file: remove misleading tests that couldn't verify
their claimed behavior, use instance properties, drop unnecessary
tear_down/uniqid/wp_set_current_user, and verify registration via
the real init path.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Feature] Related Posts [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [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