Plugin Directory


Ignore:
Timestamp:
11/07/2026 08:16:35 AM (10 hours ago)
Author:
subtleforms
Message:

SubtleForms 2.8.0

File:
1 edited

Legend:

Unmodified
Added
Removed
  • subtleforms/trunk/src/Async/AsyncDispatcher.php

    r3782922 r3789172  
    145145
    146146                return true;
     147        }
     148
     149        /**
     150         * Queue an email marketing job for an entry and one service.
     151         *
     152         * The job carries the entry ID, never the answers: they are read back
     153         * from the entry when the job runs.
     154         *
     155         * @param array $job   { service, submission_id, form_id, retry_count, feeds }.
     156         * @param int   $delay Seconds until it runs.
     157         * @return bool True if the job was scheduled.
     158         */
     159        public static function dispatchEmailMarketing( array $job, int $delay = 0 ): bool {
     160                if ( empty( $job['submission_id'] ) || empty( $job['service'] ) ) {
     161                        self::log( 'Email marketing dispatch failed: missing entry or service' );
     162                        return false;
     163                }
     164                $job['dispatch_id'] = self::dispatchId();
     165                $scheduled          = wp_schedule_single_event( time() + max( 0, $delay ), 'subtleforms_async_email_marketing', array( $job ) );
     166                if ( false === $scheduled ) {
     167                        self::log( 'Failed to schedule email marketing job', array( 'submission_id' => $job['submission_id'], 'service' => $job['service'] ) );
     168                        return false;
     169                }
     170                return true;
     171        }
     172
     173        /**
     174         * Execute an email marketing job (called by WP Cron).
     175         *
     176         * @param array $job Job from dispatchEmailMarketing().
     177         * @return void
     178         */
     179        public static function executeEmailMarketing( array $job ): void {
     180                \SubtleForms\Integrations\EmailMarketing\Sender::run( $job );
    147181        }
    148182
Note: See TracChangeset for help on using the changeset viewer.