LLMS_REST_Webhook::ping()
Perform a test ping to the delivery url
Contents
Return Return
(true|WP_Error)
Source Source
File: libraries/lifterlms-rest/includes/models/class-llms-rest-webhook.php
public function ping() {
$pre = apply_filters( 'llms_rest_webhook_pre_ping', false, $this->get( 'id' ) );
if ( false !== $pre ) {
return $pre;
}
$ping = wp_safe_remote_post(
$this->get( 'delivery_url' ),
array(
'user-agent' => $this->get_user_agent(),
'body' => sprintf( 'webhook_id=%d', $this->get( 'id' ) ),
)
);
$res_code = wp_remote_retrieve_response_code( $ping );
if ( is_wp_error( $ping ) ) {
// Translators: %s = Error message.
return new WP_Error( 'llms_rest_webhook_ping_unreachable', sprintf( __( 'Could not reach the delivery url: "%s".', 'lifterlms' ), $ping->get_error_message() ) );
}
if ( 200 !== $res_code ) {
// Translators: %d = Response code.
return new WP_Error( 'llms_rest_webhook_ping_not_200', sprintf( __( 'The delivery url returned the response code "%d".', 'lifterlms' ), absint( $res_code ) ) );
}
return true;
}
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
| Version | Description |
|---|---|
| 1.0.0-beta.1 | Introduced. |