Skip to content

[in progress] Add a core/content ability#738

Closed
jorgefilipecosta wants to merge 1 commit into
WordPress:developfrom
jorgefilipecosta:add/core-content-ability
Closed

[in progress] Add a core/content ability#738
jorgefilipecosta wants to merge 1 commit into
WordPress:developfrom
jorgefilipecosta:add/core-content-ability

Conversation

@jorgefilipecosta

@jorgefilipecosta jorgefilipecosta commented Jun 16, 2026

Copy link
Copy Markdown
Member

Summary

Adds the read-only core/content ability to the plugin, mirroring the WordPress core WP_Content_Abilities implementation (see the companion core PR) so the two stay in sync. It overrides any core-provided copy.

Retrieves one or more posts of a post type exposed to abilities: fetch a single post by id or slug, or query multiple posts filtered by post_type, status, author, parent, with a fields selector and page/per_page pagination. Output is { posts, total, total_pages }.

Security

Defense in depth: a coarse status/capability gate plus an authoritative per-post read_post check on every row; default status publish; password-protected content withheld from non-editors; uniform not-found responses to avoid leaking post existence.

Show_In_Abilities

WordPress core does not yet ship the show_in_abilities flag this ability reads, so a self-contained Show_In_Abilities component polyfills it onto curated core post types (post, page). It is structured exactly like the settings polyfill from the core/settings PR (#691), so the two merge cleanly.

This PR is independent of #691 and can be reviewed/merged on its own.

Tests

PHPUnit integration tests for the ability and the polyfill, plus an e2e spec (tests/e2e/specs/abilities/core-content.spec.js) backed by a sample-content plugin that registers an ability-exposed post type.

Open WordPress Playground Preview

Registers the read-only `core/content` ability, which retrieves one or more
posts of a post type exposed to abilities. Fetch a single post by ID or by slug,
or query multiple posts filtered by post type, status, author, or parent, with a
`fields` selector and `page`/`per_page` pagination.

Mirrors the WordPress core `WP_Content_Abilities` implementation so the two stay
in sync, and overrides any core-provided copy. A self-contained Show_In_Abilities
component polyfills the `show_in_abilities` flag onto curated core post types
(post, page) so the ability returns data on a stock site.
@jorgefilipecosta

Copy link
Copy Markdown
Member Author

Superseded by #739 — recreated directly from a branch on the repository instead of a fork.

@jorgefilipecosta jorgefilipecosta deleted the add/core-content-ability branch June 16, 2026 23:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant