submitted value, passed through * to the email engine so a form's custom template can * reference its own fields as {field_key} tags. */ public static function dispatch( $lead_id, $email, $full_name, $download_url, $file, $form_id = 0, $custom_fields = array() ) { // ── 1. Email Delivery ────────────────────────────────────────────── // ACQUIS_Email_Engine::send() picks the right template on its own: // a form-level override (Email tab), else the standalone-forms // global default (for a submission with no file), else the // file-download global default. See its pick_template() helper. $delivery_mode = get_option( 'acquis_delivery_mode', 'both' ); if ( in_array( $delivery_mode, array( 'email', 'both' ), true ) ) { ACQUIS_Email_Engine::send( $lead_id, $full_name, $email, $download_url, $file, $form_id, $custom_fields ); } // ── 2. Mailchimp ─────────────────────────────────────────────────── if ( ACQUIS_Mailchimp::is_enabled() ) { ACQUIS_Mailchimp::subscribe( $lead_id, $email, $full_name ); } // ── 3. MailWizz ──────────────────────────────────────────────────── if ( ACQUIS_Mailwizz::is_enabled() ) { // Build extra fields from mapped options $extra = self::build_mailwizz_extra_fields( $lead_id, $email, $full_name, $file ); ACQUIS_Mailwizz::subscribe( $lead_id, $email, $full_name, $extra ); } // ── 4. Brevo ─────────────────────────────────────────────────────── if ( ACQUIS_Brevo::is_enabled() ) { ACQUIS_Brevo::subscribe( $lead_id, $email, $full_name ); } // ── 5. Extensibility hook (add your own integrations) ────────────── // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound do_action( 'acquis_integrations_dispatched', $lead_id, $email, $full_name, $download_url, $file ); } /** * Build extra MailWizz custom fields from the saved mapping. * Setting: acquis_mailwizz_custom_fields = [['tag'=>'FIELD_TAG','source'=>'file_name'], ...] */ private static function build_mailwizz_extra_fields( $lead_id, $email, $full_name, $file ) { $field_map = get_option( 'acquis_mailwizz_custom_fields', array() ); $extra = array(); if ( ! is_array( $field_map ) ) return $extra; $source_values = array( 'email' => $email, 'full_name' => $full_name, 'file_name' => $file['title'] ?? '', 'file_ext' => $file['ext'] ?? '', 'site_name' => get_bloginfo( 'name' ), 'site_url' => home_url(), ); foreach ( $field_map as $mapping ) { if ( empty( $mapping['tag'] ) || empty( $mapping['source'] ) ) continue; $tag = sanitize_text_field( $mapping['tag'] ); $source = sanitize_text_field( $mapping['source'] ); if ( isset( $source_values[ $source ] ) ) { $extra[ $tag ] = $source_values[ $source ]; } } return $extra; } }