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 / NotificationsUpdateTask.php
wp-mail-smtp / src / Tasks Last commit date
Queue 6 days ago Reports 6 days ago DebugEventsCleanupTask.php 6 days ago Meta.php 6 days ago NotificationsUpdateTask.php 6 days ago Task.php 6 days ago Tasks.php 6 days ago
NotificationsUpdateTask.php
76 lines
1 <?php
2
3 namespace WPMailSMTP\Tasks;
4
5 use Exception;
6
7 /**
8 * Class NotificationsUpdateTask.
9 *
10 * @since 4.3.0
11 */
12 class NotificationsUpdateTask extends Task {
13
14 /**
15 * Action name for this task.
16 *
17 * @since 4.3.0
18 */
19 const ACTION = 'wp_mail_smtp_admin_notifications_update';
20
21 /**
22 * Class constructor.
23 *
24 * @since 4.3.0
25 */
26 public function __construct() {
27
28 parent::__construct( self::ACTION );
29 }
30
31 /**
32 * Initialize the task with all the proper checks.
33 *
34 * @since 4.3.0
35 */
36 public function init() { // phpcs:ignore WPForms.PHP.HooksMethod.InvalidPlaceForAddingHooks
37
38 // Register the action handler.
39 add_action( self::ACTION, [ $this, 'process' ] );
40
41 // Exit if notifications are disabled
42 // or this task is already scheduled.
43 if (
44 ! wp_mail_smtp()->get_notifications()->is_enabled() ||
45 Tasks::is_scheduled( self::ACTION ) !== false
46 ) {
47 return;
48 }
49
50 // Schedule the task.
51 $this->recurring(
52 strtotime( '+1 minute' ),
53 wp_mail_smtp()->get_notifications()->get_notification_update_task_interval()
54 )
55 ->unique()
56 ->register();
57 }
58
59 /**
60 * Update the notification feed.
61 *
62 * @since 4.3.0
63 */
64 public function process() {
65
66 // Delete task duplicates.
67 try {
68 $this->remove_pending( 1000 );
69 } catch ( Exception $e ) { // phpcs:ignore Generic.CodeAnalysis.EmptyStatement.DetectedCatch
70 // Do nothing.
71 }
72
73 wp_mail_smtp()->get_notifications()->update();
74 }
75 }
76