kizlo_emit_event
Emit a signed webhook event from WordPress for your Kizlo extensions to handle.
kizlo_emit_event sends a signed webhook from WordPress to your Kizlo app. Call it from your plugin wherever
something happens worth reacting to; every createEventHandler
whose declared types match receives the { type, data } payload.
Parameters
kizlo_emit_event(string $type, array|null $data = null): bool| Parameter | Type | Description |
|---|---|---|
$type | string | The event type, e.g. review.created. Handlers match on this. |
$data | array|null | Payload merged into the event's data. JSON-encoded on the way out; defaults to null. |
Returns
bool. Returns false when the plugin has no site secret or no configured webhook URLs, otherwise true once the
event is dispatched. Delivery is non-blocking and best-effort: the call returns without waiting for the app to
respond.
Examples
Emit the event from your plugin. kizlo_emit_event is global, so no import is needed:
kizlo_emit_event('review.created', [
'review_id' => $review->id,
'rating' => $review->rating,
]);Handle it in your app with a typed createEventHandler. Declare
the matching type and data schema, and the payload is typed end to end:
createEventHandler(
[{ types: ["review.created"], data: z.object({ review_id: z.number(), rating: z.number() }) }],
async (event) => {
if (event?.type !== "review.created") return
event.data.rating // typed
},
)kizlo_emit_event wraps the underlying \Kizlo\Modules\Webhook\Webhook::sendEvent() method. Use whichever
you prefer; the function is the idiomatic, hook-friendly form.