Repository navigation
Conversation
WordPress Playground🚀 Your PR has been built and is ready for testing in WordPress Playground! |
n7studios
marked this pull request as ready for review
October 20, 2026 06:33
n7studios
requested review from
a team,
ciccio-kit and
noelherrick
and removed request for
a team
October 20, 2026 06:33
noelherrick
approved these changes
Oct 20, 2026
| // Check that we're using the Kit WordPress Libraries 2.8.0 or higher. | ||
| $api = new ConvertKit_API_V4( CONVERTKIT_OAUTH_CLIENT_ID, CONVERTKIT_OAUTH_CLIENT_REDIRECT_URI ); | ||
| if ( ! method_exists( $api, 'verify_webhook_signature' ) ) { // @phpstan-ignore-line Older WordPress Libraries won't have this function. | ||
| return new WP_REST_Response( null, 503 ); |
Contributor
There was a problem hiding this comment.
503s are temporary errors - shouldn't this be a 501?
|
|
||
| // Refresh the Posts resource, which imports new Broadcasts. | ||
| if ( $import ) { | ||
| $posts = new ConvertKit_Resource_Posts( 'broadcasts_webhook' ); |
Contributor
There was a problem hiding this comment.
How heavy is this call vs. something that imports it one by one or with a list of IDs? We have the post(s) to import
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Replaces the hourly WordPress Cron event (that imported Broadcasts) with a Kit webhook, so Broadcasts are imported as soon as they're published in Kit. This also removes the reliance on WordPress Cron, which doesn't run reliably on low-traffic sites or when
DISABLE_WP_CRONis set.kit/v1/broadcasts/webhookREST API route. It receivespost.publishedevents from Kit, verifies the signature, ignores duplicate events and imports new Broadcasts.ConvertKit_Cronand theconvertkit_resource_refresh_postsCron event; the event is unscheduled on Plugin update.Testing
BroadcastsWebhookTest: registration, deletion, status, receiving events (valid, duplicate, invalid/expired signature, import disabled) and Plugin update routines.BroadcastsToPostsCest: uses Import now instead of running the Cron event.BroadcastsToPostsSettingsCest: checks the Webhook field, and that registration fails gracefully on a local site.WPCronhelper, andwp-crontrolfrom the test group.Checklist