For developers
Hooks and filters
Wynko fires WordPress action and filter hooks — every one prefixed
wynko_ — at the points where a developer deploying Wynko is most likely
to need to change or react to something. Actions let your code run after
Wynko does something; filters let your code change a value before Wynko
uses it. This is separate from the settings screen: hooks are for code,
not for the site admin clicking through a screen.
API transport
| Hook |
Type |
Fires in |
wynko_api_request_args |
filter |
Before every outgoing request to Laposta. |
wynko_api_response |
filter |
On the raw response, before Wynko decodes it. |
wynko_api_status_message |
filter |
On the human-readable text for a Laposta error. |
wynko_api_key |
filter |
On the resolved API key, whatever its source. |
wynko_api_key_verified |
action |
After a live key check (not a cached result). |
// Pull the API key from your own secrets manager instead of the database.
add_filter( 'wynko_api_key', function ( string $key ) {
return my_secrets_manager()->get( 'laposta_key' ) ?: $key;
} );
Campaigns and the campaigns block
| Hook |
Type |
Fires in |
wynko_campaigns |
filter |
On the campaign list before it’s cached and rendered. |
wynko_campaigns_block_content |
filter |
On the campaigns block’s final HTML. |
wynko_campaigns_synced |
action |
After a full sync of campaigns, lists, and fields completes. |
wynko_cache_busted |
action |
After Wynko’s caches are invalidated. |
// Hide campaigns older than 90 days.
add_filter( 'wynko_campaigns', function ( array $campaigns ) {
$cutoff = time() - 90 * DAY_IN_SECONDS;
return array_values( array_filter( $campaigns, function ( $c ) use ( $cutoff ) {
return '' === $c['sent_at'] || strtotime( $c['sent_at'] ) >= $cutoff;
} ) );
} );
| Hook |
Type |
Fires in |
wynko_form_block_content |
filter |
On the signup form block’s final HTML. |
wynko_form_fields |
filter |
On a form’s merged field definitions. |
wynko_form_submitted_values |
filter |
On a sanitized submission, before validation. |
wynko_form_subscriber_data |
filter |
On the data sent to Laposta, right before it’s sent. |
wynko_subscriber_data |
filter |
Same, but for any code path that writes a subscriber. |
wynko_form_submitted |
action |
After a signup is confirmed successful. |
wynko_form_submit_failed |
action |
When a signup fails to reach Laposta. |
wynko_form_redirect_url |
filter |
On the URL a visitor is sent to after submitting. |
wynko_form_config_saved |
action |
After an admin saves a form’s settings. |
wynko_form_subscriber_data is the one worth knowing about if you build on
top of Wynko: it runs on the data right before it’s sent to Laposta, so you
can add or adjust fields without reimplementing the Laposta call yourself.
// Tag every subscriber with the source that triggered the signup.
add_filter( 'wynko_form_subscriber_data', function ( array $fields, int $form_id, string $email, string $list_id ) {
$fields['source'] = 'website-form';
return $fields;
}, 10, 4 );
wynko_form_subscriber_data fires only for Wynko’s own signup form. Code
that writes subscribers by another path — an integration
with a different form plugin, or a direct call to Api\Subscribers::create()
— should use wynko_subscriber_data instead, which fires for every
subscriber write.
Integrations
| Hook |
Type |
Fires in |
wynko_register_integrations |
filter |
On the list of registered integrations, when the Integrations screen is built. |
Any plugin or theme adds an object implementing
Wynko\Integrations\Integration to this filter to register optional
functionality a site can switch on from Wynko → Integrations. Wynko’s
own bundled Contact Form 7 and HTML Forms bridges register the same way —
see their source for a worked example, and guard your registration so it
degrades to a no-op (not a fatal error) on a site where Wynko is absent.
Lists, fields, and sync
| Hook |
Type |
Fires in |
wynko_lists |
filter |
On list options before they’re cached. |
wynko_fields |
filter |
On one list’s field definitions before they’re cached. |
wynko_list_gone |
action |
The first time a list a form still uses is missing from Laposta. |
Activity log and alerts
| Hook |
Type |
Fires in |
wynko_log_added |
action |
After an entry is recorded. |
wynko_notification_recipients |
filter |
On the alert email’s recipient list. |
wynko_notification_sent |
action |
After a critical-error alert email is sent. |
// Forward every error-level log entry to your own alerting tool.
add_action( 'wynko_log_added', function ( string $level, string $message ) {
if ( 'error' === $level ) {
my_alerting_integration()->notify( $message );
}
} );