- 
                Notifications
    You must be signed in to change notification settings 
- Fork 33
Adding ability_class information and example #122
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding ability_class information and example #122
Conversation
| Codecov Report✅ All modified and coverable lines are covered by tests. 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           
 Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
 | 
There was a problem hiding this 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.
There was a problem hiding this 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 | 
There was a problem hiding this comment.
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.
| - 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. | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| * @return mixed|WP_Error The result of the ability execution. | |
| * @return mixed|\WP_Error The result of the ability execution. | 
There was a problem hiding this comment.
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. | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| * @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( | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 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( | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| return new WP_Error( | |
| return new \WP_Error( | 
| @gziolo @justlevine sorry, this wasn't mean to be reviewed yet, still a WIP. | 
| 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  If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. | 
| Merging this into the proper docs/prepare-6.9 branch so it can all be reviewed there. | 
* 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>
WIP, needs to be tested to verify.