Skip to content

Commit d2200c7

Browse files
committed
[Fix] Action not been triggered
1 parent 8a17cd6 commit d2200c7

File tree

6 files changed

+78
-29
lines changed

6 files changed

+78
-29
lines changed

CONTRIBUTING.md

+21
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,27 @@ And please, create a Issue about your PR.
4545

4646
## Development
4747

48+
### Pre-commit
49+
50+
Run `nano .git/hooks/pre-commit` to create a pre-commit file and past the content:
51+
52+
```
53+
#!/bin/bash
54+
55+
SOURCE_FILE="README.md"
56+
DESTINATION_FILE="docs/README.md"
57+
58+
if [ -f "$SOURCE_FILE" ]; then
59+
cp "$SOURCE_FILE" "$DESTINATION_FILE"
60+
git add "$DESTINATION_FILE"
61+
else
62+
echo "Erro: $SOURCE_FILE not found."
63+
exit 1
64+
fi
65+
```
66+
67+
And run `chmod +x .git/hooks/pre-commit` to make it executable.
68+
4869
### Templates
4970

5071
Templates are Header / Body values.

README.md

+7-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
**Tags:** cf7, contact form, zapier, integration, webhook
66
**Requires at least:** 4.7
77
**Tested up to:** 6.8
8-
**Stable tag:** 4.0.0
8+
**Stable tag:** 4.0.1
99
**Requires PHP:** 7.4
1010
**License:** GPLv2 or later
1111
**License URI:** http://www.gnu.org/licenses/gpl-2.0.html
@@ -159,6 +159,11 @@ Yes! Visit [GitHub repository](https://github.com/mariovalney/cf7-to-zapier) or
159159

160160
## Changelog ##
161161

162+
### 4.0.1 ###
163+
164+
* Fixes 'ctz_post_request_result' action not triggering on errors.
165+
* Added 'ctz_post_request_ignore_errors' filter to ignore error handle.
166+
162167
### 4.0.0 ###
163168

164169
* New feature: [TEMPLATES](https://wordpress.org/support/topic/how-templates-works).
@@ -296,7 +301,7 @@ Props to @shoreline-chrism
296301

297302
## Upgrade Notice ##
298303

299-
### 4.0.0 ###
304+
### 4.0.1 ###
300305

301306
We have a lot of new features and a new UI!
302307
The most cool new feature is templates! Take a look!

docs/README.md

+7-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
**Tags:** cf7, contact form, zapier, integration, webhook
66
**Requires at least:** 4.7
77
**Tested up to:** 6.8
8-
**Stable tag:** 4.0.0
8+
**Stable tag:** 4.0.1
99
**Requires PHP:** 7.4
1010
**License:** GPLv2 or later
1111
**License URI:** http://www.gnu.org/licenses/gpl-2.0.html
@@ -159,6 +159,11 @@ Yes! Visit [GitHub repository](https://github.com/mariovalney/cf7-to-zapier) or
159159

160160
## Changelog ##
161161

162+
### 4.0.1 ###
163+
164+
* Fixes 'ctz_post_request_result' action not triggering on errors.
165+
* Added 'ctz_post_request_ignore_errors' filter to ignore error handle.
166+
162167
### 4.0.0 ###
163168

164169
* New feature: [TEMPLATES](https://wordpress.org/support/topic/how-templates-works).
@@ -296,7 +301,7 @@ Props to @shoreline-chrism
296301

297302
## Upgrade Notice ##
298303

299-
### 4.0.0 ###
304+
### 4.0.1 ###
300305

301306
We have a lot of new features and a new UI!
302307
The most cool new feature is templates! Take a look!

modules/cf7/class-module-cf7.php

+13-13
Original file line numberDiff line numberDiff line change
@@ -355,19 +355,6 @@ public function wpcf7_mail_sent( $contact_form ) {
355355
'exception' => $exception,
356356
);
357357

358-
/**
359-
* Filter: ctz_trigger_webhook_error_message
360-
*
361-
* The 'ctz_trigger_webhook_error_message' filter change the message in case of error.
362-
* Default is CF7 error message, but you can access exception to create your own.
363-
*
364-
* You can ignore errors returning false:
365-
* add_filter( 'ctz_trigger_webhook_error_message', '__return_empty_string' );
366-
*
367-
* @since 1.4.0
368-
*/
369-
$error_message = apply_filters( 'ctz_trigger_webhook_error_message', $contact_form->message( 'mail_sent_ng' ), $exception );
370-
371358
/**
372359
* Filter: ctz_trigger_webhook_error_mails
373360
*
@@ -437,6 +424,19 @@ public function wpcf7_mail_sent( $contact_form ) {
437424
);
438425
}
439426

427+
/**
428+
* Filter: ctz_trigger_webhook_error_message
429+
*
430+
* The 'ctz_trigger_webhook_error_message' filter change the message in case of error.
431+
* Default is CF7 error message, but you can access exception to create your own.
432+
*
433+
* You can ignore errors returning false:
434+
* add_filter( 'ctz_trigger_webhook_error_message', '__return_empty_string' );
435+
*
436+
* @since 1.4.0
437+
*/
438+
$error_message = apply_filters( 'ctz_trigger_webhook_error_message', $contact_form->message( 'mail_sent_ng' ), $exception );
439+
440440
// If empty ignore after sending notification
441441
if ( empty( $error_message ) ) continue;
442442

modules/zapier/class-module-zapier.php

+23-10
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,29 @@ public function pull_the_trigger( array $data, $hook_url, $properties, $contact_
125125
*/
126126
$result = wp_remote_request( $hook_url, apply_filters( 'ctz_post_request_args', $args, $properties, $contact_form ) );
127127

128+
/**
129+
* Action: ctz_post_request_result
130+
*
131+
* You can perform a action with the result of the request.
132+
* By default we will thrown a CFTZ_Exception in webhook errors to send a notification.
133+
*
134+
* @since 1.4.0
135+
*/
136+
do_action( 'ctz_post_request_result', $result, $hook_url );
137+
138+
/**
139+
* Filter: ctz_post_request_ignore_errors
140+
*
141+
* The 'ctz_post_request_ignore_errors' filter can be used to ignore core error handler (notifications and success statuses).
142+
*
143+
* add_filter( 'ctz_post_request_ignore_errors', '__return_true' );
144+
*
145+
* @since 4.0.1
146+
*/
147+
if ( apply_filters( 'ctz_post_request_ignore_errors', false, $hook_url, $result, $contact_form ) ) {
148+
return;
149+
}
150+
128151
// If result is a WP Error, throw a Exception with the message.
129152
if ( is_wp_error( $result ) ) {
130153
throw new CFTZ_Exception( $result );
@@ -137,16 +160,6 @@ public function pull_the_trigger( array $data, $hook_url, $properties, $contact_
137160
$error->add( $code, __( 'Webhook returned a error code.', 'cf7-to-zapier' ), [ 'result' => $result ] );
138161
throw new CFTZ_Exception( $error );
139162
}
140-
141-
/**
142-
* Action: ctz_post_request_result
143-
*
144-
* You can perform a action with the result of the request.
145-
* By default we do nothing but you can throw a Exception in webhook errors.
146-
*
147-
* @since 1.4.0
148-
*/
149-
do_action( 'ctz_post_request_result', $result, $hook_url );
150163
}
151164

152165
/**

readme.txt

+7-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Donate link: https://www.paypal.com/donate?campaign_id=9AA82JCSNWNFS
55
Tags: cf7, contact form, zapier, integration, webhook
66
Requires at least: 4.7
77
Tested up to: 6.8
8-
Stable tag: 4.0.0
8+
Stable tag: 4.0.1
99
Requires PHP: 7.4
1010
License: GPLv2 or later
1111
License URI: http://www.gnu.org/licenses/gpl-2.0.html
@@ -153,6 +153,11 @@ Yes! Visit [GitHub repository](https://github.com/mariovalney/cf7-to-zapier) or
153153

154154
== Changelog ==
155155

156+
= 4.0.1 =
157+
158+
* Fixes 'ctz_post_request_result' action not triggering on errors.
159+
* Added 'ctz_post_request_ignore_errors' filter to ignore error handle.
160+
156161
= 4.0.0 =
157162

158163
* New feature: [TEMPLATES](https://wordpress.org/support/topic/how-templates-works).
@@ -290,7 +295,7 @@ Props to @shoreline-chrism
290295

291296
== Upgrade Notice ==
292297

293-
= 4.0.0 =
298+
= 4.0.1 =
294299

295300
We have a lot of new features and a new UI!
296301
The most cool new feature is templates! Take a look!

0 commit comments

Comments
 (0)