Skip to content

Improve the properties validation when using ability_class during registration #53

@gziolo

Description

@gziolo

I left a note here about making execute_callback optional when ability_class is passed as one of the properties:

invoke on Content_Rewrite_Tool would have to be static to fit here because execute_callback is mandatory at the moment during ability registration (label and description, too). If that is too limiting, we could revisit $properties validation. I also think that we should make $properties mandatory, as you still must provide these 3 properties, so validation passes before the ability instance gets created.

I have an example from @felixarntz of using ability_class from the AI chatbot demo using the PHP AI Client SDK presented at WC US:

https://github.com/felixarntz/wp-ai-sdk-chatbot-demo/blob/326266fd62fc805ceac0dfd4fe71cd3cc3e7cad3/includes/Abilities/Abilities_Registrar.php#L26-L44

Image

It's where not only the execute_callback was mocked, but also the description.

Proposal

  • Make $properties mandatory.
  • Make execute_callback optional when ability_class gets passed.
  • Consider making label and description optional when ability_class gets passed, with the assumption that the developer will set it in the custom class extending WP_Ability.

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions