WordPress at Your Fingertips
function is not described

WC_Webhook::deliver_ping() public WC 2.2.0

Send a test ping to the delivery URL, sent when the webhook is first created.

{} It's a method of the class: WC_Webhook{}

No Hooks.

Return

true|false|WP_Error.

Usage

$WC_Webhook = new WC_Webhook();
$WC_Webhook->deliver_ping();

Changelog

Since 2.2.0 Introduced.

Code of WC_Webhook::deliver_ping() WC 5.9.0

public function deliver_ping() {
	$args = array(
		'user-agent' => sprintf( 'WooCommerce/%s Hookshot (WordPress/%s)', Constants::get_constant( 'WC_VERSION' ), $GLOBALS['wp_version'] ),
		'body'       => 'webhook_id=' . $this->get_id(),
	);

	$test          = wp_safe_remote_post( $this->get_delivery_url(), $args );
	$response_code = wp_remote_retrieve_response_code( $test );

	if ( is_wp_error( $test ) ) {
		/* translators: error message */
		return new WP_Error( 'error', sprintf( __( 'Error: Delivery URL cannot be reached: %s', 'woocommerce' ), $test->get_error_message() ) );
	}

	if ( 200 !== $response_code ) {
		/* translators: error message */
		return new WP_Error( 'error', sprintf( __( 'Error: Delivery URL returned response code: %s', 'woocommerce' ), absint( $response_code ) ) );
	}

	$this->set_pending_delivery( false );
	$this->save();

	return true;
}