| @@ -622,26 +622,8 @@ | ||
| 622 | 622 | return false; |
| 623 | 623 | } |
| 624 | 624 | |
| 625 | 625 | /** |
| 626 | - * Enable / Disable default mail. | |
| 627 | - * | |
| 628 | - * @param bool $status Enable (true) or disable (false) the default mail. | |
| 629 | - * @param int $postId The ID of the Post / Form. | |
| 630 | - * | |
| 631 | - * @since 2.3.3 | |
| 632 | - */ | |
| 633 | - $sendDefaultMail = (bool) apply_filters( 'f12_cf7_doubleoptin_send_default_mail', true, $OptIn->get_cf_form_id() ); | |
| 634 | - | |
| 635 | - /** | |
| 636 | - * Bind the follow-up plan before the confirmation is saved (see | |
| 637 | - * AbstractFormIntegration::validateOptIn). False when no adapter | |
| 638 | - * handles this integration → previous behaviour below. | |
| 639 | - */ | |
| 640 | - $coordinator = \Forge12\DoubleOptIn\FollowUp\FollowUpCoordinator::instance(); | |
| 641 | - $managed = $coordinator !== null && $coordinator->plan( $OptIn, $sendDefaultMail ); | |
| 642 | - | |
| 643 | - /** | |
| 644 | 626 | * Confirm the OptIn. |
| 645 | 627 | */ |
| 646 | 628 | if ( $this->updateOptInByHash( $hash, 1, $OptIn ) <= 0 ) { |
| 647 | 629 | $this->get_logger()->info( 'OptIn update failed', [ |
| @@ -653,23 +635,17 @@ | ||
| 653 | 635 | } |
| 654 | 636 | |
| 655 | 637 | $this->setValidationStatus( 'confirmed' ); |
| 656 | 638 | |
| 657 | - if ( $managed ) { | |
| 658 | - // Planned actions (skipped ones included) are recorded by the | |
| 659 | - // coordinator; trigger_default_mail is not fired for managed | |
| 660 | - // opt-ins, so no listener can replay them a second time. | |
| 661 | - if ( $sendDefaultMail ) { | |
| 662 | - do_action( 'f12_cf7_doubleoptin_before_send_default_mail', $OptIn ); | |
| 663 | - } | |
| 664 | - $coordinator->run( $OptIn, \Forge12\DoubleOptIn\FollowUp\FollowUpAttempt::TRIGGER_CONFIRM ); | |
| 665 | - if ( $sendDefaultMail ) { | |
| 666 | - do_action( 'f12_cf7_doubleoptin_after_send_default_mail', $OptIn ); | |
| 667 | - } | |
| 668 | - return true; | |
| 669 | - } | |
| 670 | - | |
| 671 | - if ( ! $sendDefaultMail ) { | |
| 639 | + /** | |
| 640 | + * Enable / Disable default mail. | |
| 641 | + * | |
| 642 | + * @param bool $status Enable (true) or disable (false) the default mail. | |
| 643 | + * @param int $postId The ID of the Post / Form. | |
| 644 | + * | |
| 645 | + * @since 2.3.3 | |
| 646 | + */ | |
| 647 | + if ( ! apply_filters( 'f12_cf7_doubleoptin_send_default_mail', true, $OptIn->get_cf_form_id() ) ) { | |
| 672 | 648 | $this->get_logger()->info( 'Default mail disabled for OptIn', [ |
| 673 | 649 | 'plugin' => 'double-opt-in', |
| 674 | 650 | 'form_id' => $OptIn->get_cf_form_id(), |
| 675 | 651 | 'optin_id' => $OptIn->get_id(), |
| @@ -1097,13 +1073,11 @@ | ||
| 1097 | 1073 | /** |
| 1098 | 1074 | * Validate if the optin is enabled. |
| 1099 | 1075 | */ |
| 1100 | 1076 | protected function isOptinEnabled( int $formId ): bool { |
| 1101 | - // Disable optin sending while our own post-confirmation replay runs. | |
| 1102 | - // Not `isset( $_GET['optin'] )`: that is client input and let a | |
| 1103 | - // submitter switch the double opt-in off. | |
| 1104 | - if ( \Forge12\DoubleOptIn\Integration\AbstractFormIntegration::isReplaying() ) { | |
| 1105 | - $this->get_logger()->debug( 'Optin disabled during post-confirmation replay', [ | |
| 1077 | + // Disable optin sending if the optin flag is set. | |
| 1078 | + if ( isset( $_GET['optin'] ) ) { | |
| 1079 | + $this->get_logger()->debug( 'Optin disabled due to optin flag in GET request', [ | |
| 1106 | 1080 | 'plugin' => 'double-opt-in', |
| 1107 | 1081 | 'class' => __CLASS__, |
| 1108 | 1082 | 'method' => __METHOD__, |
| 1109 | 1083 | ] ); |
| @@ -1212,23 +1186,8 @@ | ||
| 1212 | 1186 | 'class' => __CLASS__, |
| 1213 | 1187 | 'method' => __METHOD__, |
| 1214 | 1188 | 'hash' => $hash, |
| 1215 | 1189 | ] ); |
| 1216 | - return; | |
| 1217 | - } | |
| 1218 | - | |
| 1219 | - /** | |
| 1220 | - * Only for this integration's own opt-in, only right after it was | |
| 1221 | - * confirmed in this request, and only when no follow-up adapter | |
| 1222 | - * owns the files. Previously any `?optin=` request — an expired | |
| 1223 | - * link, a second click, another integration's hash — deleted the | |
| 1224 | - * stored files, including ones a pending action still needed. | |
| 1225 | - */ | |
| 1226 | - if ( ! $OptIn->isType( $this->type ) || self::$validationStatus !== 'confirmed' ) { | |
| 1227 | - return; | |
| 1228 | - } | |
| 1229 | - $coordinator = \Forge12\DoubleOptIn\FollowUp\FollowUpCoordinator::instance(); | |
| 1230 | - if ( $coordinator !== null && $coordinator->adapterFor( $OptIn ) !== null ) { | |
| 1231 | 1190 | return; |
| 1232 | 1191 | } |
| 1233 | 1192 | |
| 1234 | 1193 | /** |