| @@ -1,36 +1,62 @@ | ||
| 1 | -<?php | |
| 2 | - | |
| 3 | -namespace forge12\contactform7\CF7DoubleOptIn { | |
| 4 | - if (!defined('ABSPATH')) { | |
| 5 | - exit; | |
| 6 | - } | |
| 7 | - | |
| 8 | - /** | |
| 9 | - * Class ControllerCF7 | |
| 10 | - * | |
| 11 | - * @package forge12\contactform7\CF7OptIn | |
| 12 | - */ | |
| 13 | - class ControllerCF7 | |
| 14 | - { | |
| 15 | - /** | |
| 16 | - * Admin constructor. | |
| 17 | - */ | |
| 18 | - public function __construct() | |
| 19 | - { | |
| 20 | - require_once('Frontend.class.php'); | |
| 21 | - $Frontend = new Frontend(); | |
| 22 | - | |
| 23 | - require_once('Backend.class.php'); | |
| 24 | - $Backend = new Backend(); | |
| 25 | - | |
| 26 | - require_once('ConditionalFields.class.php'); | |
| 27 | - $CF = new ConditionalFields(); | |
| 28 | - } | |
| 29 | - } | |
| 30 | - | |
| 31 | - add_action('f12_cf7_doubleoptin_ui_after_load_compatibilities', function(){ | |
| 32 | - if(function_exists('wpcf7')) { | |
| 33 | - $Controller = new ControllerCF7(); | |
| 34 | - } | |
| 35 | - }); | |
| 1 | +<?php | |
| 2 | + | |
| 3 | +namespace forge12\contactform7\CF7DoubleOptIn { | |
| 4 | + if ( ! defined( 'ABSPATH' ) ) { | |
| 5 | + exit; | |
| 6 | + } | |
| 7 | + | |
| 8 | + /** | |
| 9 | + * Class ControllerCF7 | |
| 10 | + * | |
| 11 | + * @package forge12\contactform7\CF7OptIn | |
| 12 | + * | |
| 13 | + * @deprecated 4.0.0 This controller is part of the legacy system. | |
| 14 | + * Use the filter 'f12_cf7_doubleoptin_use_new_integration_system' to switch | |
| 15 | + * to the new event-based integration system. | |
| 16 | + */ | |
| 17 | + class ControllerCF7 extends BaseController { | |
| 18 | + /** | |
| 19 | + * Admin constructor. | |
| 20 | + */ | |
| 21 | + public function on_init() { | |
| 22 | + /** | |
| 23 | + * Check if the new integration system is active. | |
| 24 | + * If so, skip loading the legacy classes to avoid duplicate processing. | |
| 25 | + * | |
| 26 | + * @since 4.0.0 | |
| 27 | + */ | |
| 28 | + if ( apply_filters( 'f12_cf7_doubleoptin_use_new_integration_system', true ) ) { | |
| 29 | + $this->get_logger()->info( 'Legacy CF7 controller skipped - new integration system is active', [ | |
| 30 | + 'plugin' => 'double-opt-in', | |
| 31 | + 'class' => __CLASS__, | |
| 32 | + ] ); | |
| 33 | + return; | |
| 34 | + } | |
| 35 | + | |
| 36 | + $this->get_logger()->debug( 'CF7 integration on_init started', [ | |
| 37 | + 'plugin' => 'double-opt-in', | |
| 38 | + 'class' => __CLASS__, | |
| 39 | + 'method' => __METHOD__, | |
| 40 | + ] ); | |
| 41 | + | |
| 42 | + require_once( 'CF7Frontend.class.php' ); | |
| 43 | + $Frontend = new CF7Frontend( $this->get_logger() ); | |
| 44 | + $this->get_logger()->debug( 'CF7Frontend initialized', [ | |
| 45 | + 'plugin' => 'double-opt-in', | |
| 46 | + ] ); | |
| 47 | + | |
| 48 | + require_once( 'CF7Backend.class.php' ); | |
| 49 | + $Backend = new CF7Backend( $this->get_logger() ); | |
| 50 | + $this->get_logger()->debug( 'CF7Backend initialized', [ | |
| 51 | + 'plugin' => 'double-opt-in', | |
| 52 | + ] ); | |
| 53 | + | |
| 54 | + require_once( 'CF7ConditionalFields.class.php' ); | |
| 55 | + $CF = new CF7ConditionalFields( $this->get_logger() ); | |
| 56 | + $this->get_logger()->debug( 'CF7ConditionalFields initialized', [ | |
| 57 | + 'plugin' => 'double-opt-in', | |
| 58 | + ] ); | |
| 59 | + } | |
| 60 | + | |
| 61 | + } | |
| 36 | 62 | } |