PluginProbe ʕ •ᴥ•ʔ
JetFormBuilder — Dynamic Blocks Form Builder / 3.5.4
JetFormBuilder — Dynamic Blocks Form Builder v3.5.4
3.6.3.1 3.6.3 3.6.2.2 3.6.2.1 3.6.2 3.6.1.1 3.6.1 3.6.0.1 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.3.0 1.3.1 1.3.2 1.3.3 1.4.0 1.4.1 1.4.2 1.4.3 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.1.0 2.1.1 2.1.10 2.1.11 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.1.9 3.0.0 3.0.0.1 3.0.0.2 3.0.0.3 3.0.1 3.0.1.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.0.1 3.1.1 3.1.2 3.1.3 3.1.4 3.1.5 3.1.6 3.1.7 3.1.8 3.1.9 3.2.0 3.2.1 3.2.2 3.2.3 3.3.0 3.3.1 3.3.2 3.3.3 3.3.3.1 3.3.4 3.3.4.1 3.3.4.2 3.4.0 3.4.1 3.4.2 3.4.3 3.4.4 3.4.5 3.4.5.1 3.4.5.2 3.4.6 3.4.7 3.4.7.1 3.5.0 3.5.1 3.5.1.1 3.5.1.2 3.5.2 3.5.2.1 3.5.3 3.5.4 3.5.5 3.5.6 3.5.6.1 3.5.6.2 3.5.6.3 3.6.0
jetformbuilder / modules / actions-v2 / call-webhook / call-webhook-action.php
jetformbuilder / modules / actions-v2 / call-webhook Last commit date
assets 1 year ago call-webhook-action.php 1 year ago call-webhook.php 1 year ago
call-webhook-action.php
95 lines
1 <?php
2
3 namespace JFB_Modules\Actions_V2\Call_Webhook;
4
5 // If this file is called directly, abort.
6 use Jet_Form_Builder\Actions\Action_Handler;
7 use Jet_Form_Builder\Actions\Types\Base;
8 use Jet_Form_Builder\Exceptions\Action_Exception;
9 use JFB_Modules\Rich_Content;
10
11 if ( ! defined( 'WPINC' ) ) {
12 die;
13 }
14
15 /**
16 * Define Base_Type class
17 */
18 class Call_Webhook_Action extends Base {
19
20 public function get_name() {
21 return __( 'Call Webhook', 'jet-form-builder' );
22 }
23
24 public function get_id() {
25 return 'call_webhook';
26 }
27
28 public function action_attributes() {
29 return array(
30 'webhook_url' => array(
31 'default' => '',
32 ),
33 );
34 }
35
36 public function do_action( array $request, Action_Handler $handler ) {
37 $webhook_url = ! empty( $this->settings['webhook_url'] ) ? trim( $this->settings['webhook_url'] ) : false;
38 $webhook_timeout = ! empty( $this->settings['webhook_timeout'] ) ? (int) $this->settings['webhook_timeout'] : false;
39
40 if ( ! $webhook_url ) {
41 throw new Action_Exception(
42 'failed',
43 esc_html__( 'Empty webhook url', 'jet-form-builder' )
44 );
45 }
46
47 $args = array(
48 'body' => $request,
49 );
50
51 if ( false !== $webhook_timeout ) {
52 $args['timeout'] = $webhook_timeout;
53 }
54
55 /**
56 * Filter webhook arguments
57 */
58 $args = apply_filters(
59 'jet-form-builder/action/webhook/request-args',
60 $args,
61 $this->settings,
62 $this
63 );
64
65 $webhook_url = Rich_Content\Module::rich( $webhook_url );
66
67 $webhook_url = apply_filters(
68 'jet-form-builder/action/webhook/request-url',
69 $webhook_url,
70 $this
71 );
72
73 $webhook_url = esc_url_raw( $webhook_url );
74
75 if ( ! $webhook_url ) {
76 throw new Action_Exception( 'failed', 'empty_webhook_url' );
77 }
78
79 $response = wp_remote_post( $webhook_url, $args );
80
81 if ( $response instanceof \WP_Error ) {
82 throw new Action_Exception(
83 'failed',
84 esc_html__( 'Remote request returned error', 'jet-form-builder' ),
85 $response // phpcs:ignore WordPress.Security.EscapeOutput.ExceptionNotEscaped
86 );
87 }
88 /**
89 * Fires whe webhook response received
90 */
91 do_action( 'jet-form-builder/action/webhook/response', $response, $this->settings, $this );
92 }
93
94 }
95