Skip to content

Conversation

@jonathanbossenger
Copy link
Contributor

@jonathanbossenger jonathanbossenger commented Oct 15, 2025

WIP, needs to be tested to verify.

@codecov
Copy link

codecov bot commented Oct 15, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.65%. Comparing base (bb0ef4a) to head (0aae7bb).
⚠️ Report is 1 commits behind head on docs/prepare-6.9.

Additional details and impacted files
@@                 Coverage Diff                 @@
##             docs/prepare-6.9     #122   +/-   ##
===================================================
  Coverage               86.65%   86.65%           
  Complexity                148      148           
===================================================
  Files                      18       18           
  Lines                     982      982           
  Branches                   89       89           
===================================================
  Hits                      851      851           
  Misses                    131      131           
Flag Coverage Δ
javascript 93.04% <ø> (ø)
unit 84.70% <ø> (ø)

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.

Copy link
Member

@gziolo gziolo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I read the changes proposed and everything seemed to be correct. Nice understanding of the use cases it tries to cover. It’s also primarily for projects offering collections of abilities that share similar characteristics like logging, debugging, social permission checks, etc.

Copy link
Contributor

@justlevine justlevine left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did a quick scan from my phone. mostly nits

docs/php-api.md Outdated
- Your custom class **must** extend `WP_Ability`
- The custom class is only used to instantiate the ability - the `ability_class` parameter is not stored as a property of the ability
- You can override protected methods like `do_execute()`, `validate_input()`, or `validate_output()` to customize behavior
- You can add public methods to provide additional functionality specific to your ability
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They can add any sort of method, not sure if we want to encourage public methods with an explicit callout.

Suggested change
- You can add public methods to provide additional functionality specific to your ability
- You can add custom methods to provide additional functionality specific to your ability

docs/php-api.md Outdated
* to customize behavior before or after the standard execution.
*
* @param mixed $input Optional. The input data for the ability.
* @return mixed|WP_Error The result of the ability execution.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @return mixed|WP_Error The result of the ability execution.
* @return mixed|\WP_Error The result of the ability execution.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternatively, this could be a lovely place to demonstrate {@inheritDoc} and leave off the types annotations for better future compat

docs/php-api.md Outdated
* to perform validation logic that's specific to this ability.
*
* @param int $post_id The post ID to validate.
* @return true|WP_Error True if valid, WP_Error if invalid.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @return true|WP_Error True if valid, WP_Error if invalid.
* @return true|\WP_Error True if valid, WP_Error if invalid.

docs/php-api.md Outdated
// Check if the post exists
$post = get_post( $post_id );
if ( ! $post ) {
return new WP_Error(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return new WP_Error(
return new \WP_Error(

docs/php-api.md Outdated

// Check if the post is published
if ( 'publish' !== $post->post_status ) {
return new WP_Error(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return new WP_Error(
return new \WP_Error(

@jonathanbossenger
Copy link
Contributor Author

@gziolo @justlevine sorry, this wasn't mean to be reviewed yet, still a WIP.

@jonathanbossenger jonathanbossenger marked this pull request as ready for review October 16, 2025 07:52
@github-actions
Copy link

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: jonathanbossenger <psykro@git.wordpress.org>
Co-authored-by: gziolo <gziolo@git.wordpress.org>
Co-authored-by: justlevine <justlevine@git.wordpress.org>

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

@jonathanbossenger
Copy link
Contributor Author

Merging this into the proper docs/prepare-6.9 branch so it can all be reviewed there.

@jonathanbossenger jonathanbossenger merged commit fd9c918 into docs/prepare-6.9 Oct 16, 2025
21 of 36 checks passed
@jonathanbossenger jonathanbossenger deleted the docs/prepare-6.9-ability_class branch October 16, 2025 07:53
jonathanbossenger added a commit that referenced this pull request Oct 21, 2025
* Docs refactor in prepartion for WordPress 6.9

Moved all PHP related docs to the php-api.md
Created new README.md file with correct doc ordering
Removed doc file numbering
Updating main repo README.md doc links

* Updating hooks

Adding reference for abilities_api_init

Moving hook registration in code examples above callback function for better readability

* Adding other category functions to PHP API

* Update README.md with direct link to docs README

* Adding ability_class information and example (#122)

* Adding ability_class information and example

* Adding contributing docs to Documenation section in the readme

* Fixing outdated link

* PR review updates

* Adding REST API docs updates from #120

* JavaScript client updates from #120

Co-authored-by: jonathanbossenger <psykro@git.wordpress.org>
Co-authored-by: gziolo <gziolo@git.wordpress.org>
Co-authored-by: aaronware <aware@git.wordpress.org>
Co-authored-by: galatanovidiu <ovidiu-galatan@git.wordpress.org>
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.

4 participants