Skip to content

Conversation

@0xAmaan
Copy link

@0xAmaan 0xAmaan commented Nov 25, 2025

Summary

Implements standardized CRUD abilities for WordPress posts that work uniformly across all post types (built-in and custom), as requested in #84.

New abilities

Ability Description
core/create-post Create posts with title, content, excerpt, status
core/get-post Retrieve a single post by ID
core/list-posts List posts with pagination, filtering, and search
core/update-post Partial updates to existing posts
core/delete-post Soft delete (trash) or permanent deletion

Key features

  • Works with all post types - Parameterized via post_type field
  • Respects WordPress capabilities - Full permission callbacks using current_user_can()
  • Input/output validation - JSON Schema for all abilities
  • Proper error handling - Returns WP_Error with appropriate HTTP status codes
  • REST API ready - All abilities exposed via show_in_rest: true
  • Semantic annotations - readonly, destructive, idempotent hints for tooling

Test plan

  • All existing tests pass
  • New unit tests cover all 5 CRUD abilities
  • Permission checks tested for different user roles (admin, editor, subscriber)
  • Error handling tested for edge cases (nonexistent posts, invalid input)

Closes #84

Implements standardized Create, Read, Update, and Delete abilities for WordPress posts that work uniformly across all post types (built-in and custom).

New abilities:
- core/create-post: Create posts with title, content, excerpt, status
- core/get-post: Retrieve a single post by ID
- core/list-posts: List posts with pagination, filtering, and search
- core/update-post: Partial updates to existing posts
- core/delete-post: Soft delete (trash) or permanent deletion

Features:
- Respects WordPress capabilities system for all operations
- Supports all post types via post_type parameter
- Full input/output schema validation
- Proper error handling with WP_Error and HTTP status codes
- REST API exposure via show_in_rest annotation
- Semantic annotations (readonly, destructive, idempotent)

Closes WordPress#84
@github-actions
Copy link

github-actions bot commented Nov 25, 2025

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: 0xAmaan <0xamaan@git.wordpress.org>
Co-authored-by: gziolo <gziolo@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@codecov
Copy link

codecov bot commented Nov 25, 2025

Codecov Report

❌ Patch coverage is 22.07792% with 420 lines in your changes missing coverage. Please review.
✅ Project coverage is 64.82%. Comparing base (1ebde3f) to head (c74389d).

Files with missing lines Patch % Lines
includes/abilities/wp-post-abilities.php 22.24% 416 Missing ⚠️
includes/bootstrap.php 0.00% 4 Missing ⚠️
Additional details and impacted files
@@              Coverage Diff              @@
##              trunk     #153       +/-   ##
=============================================
- Coverage     80.46%   64.82%   -15.64%     
  Complexity      178      178               
=============================================
  Files            20       21        +1     
  Lines          1474     2013      +539     
  Branches        120      120               
=============================================
+ Hits           1186     1305      +119     
- Misses          288      708      +420     
Flag Coverage Δ
javascript 94.61% <ø> (ø)
unit 58.90% <22.07%> (-17.42%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Add phpcs:ignore comments for WordPress.WP.Capabilities.Undetermined warnings.
These are false positives - the capabilities are dynamically retrieved from
post type objects which is a valid WordPress pattern.
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.

Create ablities for CRUD operations that work with all post types

1 participant