Dispatches an event to WordPress action hooks.
Description
Converts the event class name to a WordPress action hook name and fires it.
For example, BeforeGenerateResultEvent becomes wp_ai_client_before_generate_result.
Parameters
$eventobjectrequired- The event object to dispatch.
Source
public function dispatch( object $event ): object {
$event_name = $this->get_hook_name_portion_for_event( $event );
/**
* Fires when an AI client event is dispatched.
*
* The dynamic portion of the hook name, `$event_name`, refers to the
* snake_case version of the event class name, without the `_event` suffix.
*
* For example, an event class named `BeforeGenerateResultEvent` will fire the
* `wp_ai_client_before_generate_result` action hook.
*
* In practice, the available action hook names are:
*
* - wp_ai_client_before_generate_result
* - wp_ai_client_after_generate_result
*
* @since 7.0.0
*
* @param object $event The event object.
*/
do_action( "wp_ai_client_{$event_name}", $event );
return $event;
}
Hooks
- do_action( “wp_ai_client_{$event_name}”,
object $event ) Fires when an AI client event is dispatched.
Changelog
| Version | Description |
|---|---|
| 7.0.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.