'alt_text_generated', 'attachment_id' => (int) $post_ID, 'alt_text' => isset( $result['alt_text'] ) ? $result['alt_text'] : '', 'title' => isset( $result['title'] ) ? $result['title'] : '', 'image_url' => $image ? $image[0] : '', 'site_url' => home_url(), 'timestamp' => current_time( 'c' ), ); /** * Filter the outgoing webhook payload. * * @param array $payload The webhook payload. * @param int $post_ID Attachment ID. * @param array $result Generation result. */ $payload = apply_filters( 'aatg_webhook_payload', $payload, $post_ID, $result ); $body = wp_json_encode( $payload ); $headers = array( 'Content-Type' => 'application/json' ); $secret = get_option( 'aatg_webhook_secret', '' ); if ( ! empty( $secret ) ) { $headers['X-AATG-Signature'] = 'sha256=' . hash_hmac( 'sha256', $body, $secret ); } // wp_safe_remote_post() refuses private/internal hosts. wp_safe_remote_post( $url, array( 'headers' => $headers, 'body' => $body, 'timeout' => 5, 'blocking' => false, ) ); } add_action( 'aatg_after_generation', 'aatg_dispatch_webhook', 10, 2 );