PluginProbe ʕ •ᴥ•ʔ
WP Mail SMTP by WPForms – The Most Popular SMTP and Email Log Plugin / 4.9.0
WP Mail SMTP by WPForms – The Most Popular SMTP and Email Log Plugin v4.9.0
4.9.0 0.9.6 1.0.0 1.0.1 1.0.2 1.1.0 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.3.0 1.3.1 1.3.2 1.3.3 1.4.0 1.4.1 1.4.2 1.5.0 1.5.1 1.5.2 1.6.0 1.6.2 1.7.0 1.7.1 1.8.0 1.8.1 1.9.0 2.0.0 2.0.1 2.1.1 2.2.1 2.3.1 2.4.0 2.5.0 2.5.1 2.6.0 2.7.0 2.8.0 2.9.0 3.0.1 3.0.2 3.0.3 3.1.0 3.10.0 3.11.0 3.11.1 3.2.0 3.2.1 3.3.0 3.4.0 3.5.0 3.5.1 3.5.2 3.6.1 3.7.0 3.8.0 3.8.2 3.9.0 4.0.1 4.1.0 4.1.1 4.2.0 4.3.0 4.4.0 4.5.0 4.6.0 4.7.0 4.7.1 4.8.0 trunk 0.10.0 0.10.1 0.11.1 0.11.2 0.3.1 0.3.2 0.4 0.4.1 0.4.2 0.5.0 0.5.1 0.5.2 0.6 0.7 0.8 0.8.2 0.8.3 0.8.4 0.8.5 0.8.6 0.8.7 0.9.0 0.9.1 0.9.2 0.9.3 0.9.4 0.9.5
wp-mail-smtp / src / Tasks / Queue / ProcessQueueTask.php
wp-mail-smtp / src / Tasks / Queue Last commit date
CleanupQueueTask.php 6 days ago ProcessQueueTask.php 6 days ago SendEnqueuedEmailTask.php 6 days ago
ProcessQueueTask.php
85 lines
1 <?php
2
3 namespace WPMailSMTP\Tasks\Queue;
4
5 use WPMailSMTP\Tasks\Task;
6 use WPMailSMTP\Tasks\Tasks;
7
8 /**
9 * Class ProcessQueueTask.
10 *
11 * @since 4.0.0
12 */
13 class ProcessQueueTask extends Task {
14
15 /**
16 * Action name for this task.
17 *
18 * @since 4.0.0
19 */
20 const ACTION = 'wp_mail_smtp_queue_process';
21
22 /**
23 * Class constructor.
24 *
25 * @since 4.0.0
26 */
27 public function __construct() {
28
29 parent::__construct( self::ACTION );
30 }
31
32 /**
33 * Initialize the task.
34 *
35 * @since 4.0.0
36 */
37 public function init() { // phpcs:ignore WPForms.PHP.HooksMethod.InvalidPlaceForAddingHooks
38
39 // Register the action handler.
40 add_action( self::ACTION, [ $this, 'process' ] );
41
42 // Cleanup completed task occurrences.
43 add_action( 'action_scheduler_after_process_queue', [ $this, 'cleanup' ] );
44
45 // Exit if this task the queue is disabled, or it's already scheduled.
46 if (
47 ! wp_mail_smtp()->get_queue()->is_enabled() ||
48 Tasks::is_scheduled( self::ACTION ) !== false
49 ) {
50 return;
51 }
52
53 // Schedule the task.
54 $this->recurring( strtotime( 'now' ), MINUTE_IN_SECONDS )
55 ->unique()
56 ->register();
57 }
58
59 /**
60 * Perform email sending.
61 *
62 * @since 4.0.0
63 */
64 public function process() {
65
66 $queue = wp_mail_smtp()->get_queue();
67
68 $queue->process();
69
70 if ( ! $queue->is_enabled() ) {
71 $this->cancel_force();
72 }
73 }
74
75 /**
76 * Cleanup completed tasks.
77 *
78 * @since 4.1.0
79 */
80 public function cleanup() {
81
82 $this->remove_completed( 10 );
83 }
84 }
85