Skip to content
Corex

NewsletterServiceProvider

Corex\Newsletter\NewsletterServiceProvider · class · Add-ons layer

Wires the newsletter: bindings, the subscribers table, the newsletter_topic taxonomy, the confirm/unsubscribe link handler, the subscribe REST route, the on-publish notifier, and the email templates (when Corex Mail is active). The table is declared, not created: the migration runner creates it when the version stored for the site differs from the one here, from an admin page, cron, wp corex migrate or a network’s new site. Change the columns and raise the version with them.

Declare the subscribers table to the Data screen, register the topic taxonomy, and register the email templates with Corex Mail.

Handle the signed confirm/unsubscribe links from the emails. The token is the authenticator (unforgeable), so these GET links need no nonce — the standard email-link pattern.

subscribe(WP_REST_Request $request): WP_REST_Response

Section titled “subscribe(WP_REST_Request $request): WP_REST_Response”

onPublish(string $new, string $old, WP_Post $post): void

Section titled “onPublish(string $new, string $old, WP_Post $post): void”