copyhackers / airstory-wp

Send your blog posts from Airstory writing software to WordPress for publication.
https://wordpress.org/plugins/airstory
MIT License
4 stars 1 forks source link

Attempt to resolve the webhook URI before connecting to Airstory #77

Closed stevegrunwell closed 6 years ago

stevegrunwell commented 6 years ago

This PR adds the Airstory\Connection\get_webhook_uri() function, which performs additional checks against the WP REST API before connecting to Airstory.

Rather than relying on the (self-reporting) output of get_rest_url(), get_webhook_uri() will send an HTTP HEAD request to that endpoint to see if any redirects are in-play. The resulting URI is then stored in the object cache, to be recalculated only when a significant change (such as a domain change) is made to the site.

This approach should help reduce the number of cases where the Airstory target and effective path (see this comment in #74 for details) do not match.