| Server IP : 43.141.50.122 / Your IP : 113.219.202.141 Web Server : Apache System : Linux VM-8-5-opencloudos 6.6.34-9.oc9.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Jun 19 19:35:45 CST 2024 x86_64 User : www ( 1000) PHP Version : 8.1.27 Disable Function : passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /www/wwwroot/www.ucppt.com/wp-content/plugins/easy-wp-smtp/src/Tasks/ |
Upload File : |
<?php
namespace EasyWPSMTP\Tasks;
use Exception;
/**
* Class NotificationsUpdateTask.
*
* @since 2.8.0
*/
class NotificationsUpdateTask extends Task {
/**
* Action name for this task.
*
* @since 2.8.0
*/
const ACTION = 'easy_wp_smtp_admin_notifications_update';
/**
* Class constructor.
*
* @since 2.8.0
*/
public function __construct() {
parent::__construct( self::ACTION );
}
/**
* Initialize the task with all the proper checks.
*
* @since 2.8.0
*/
public function init() { // phpcs:ignore WPForms.PHP.HooksMethod.InvalidPlaceForAddingHooks
// Register the action handler.
add_action( self::ACTION, [ $this, 'process' ] );
// Exit if notifications are disabled
// or this task is already scheduled.
if (
! easy_wp_smtp()->get_notifications()->is_enabled() ||
Tasks::is_scheduled( self::ACTION ) !== false
) {
return;
}
// Schedule the task.
$this->recurring(
strtotime( '+1 minute' ),
easy_wp_smtp()->get_notifications()->get_notification_update_task_interval()
)
->unique()
->register();
}
/**
* Update the notification feed.
*
* @since 2.8.0
*/
public function process() {
// Delete task duplicates.
try {
$this->remove_pending( 1000 );
} catch ( Exception $e ) { // phpcs:ignore Generic.CodeAnalysis.EmptyStatement.DetectedCatch
// Do nothing.
}
easy_wp_smtp()->get_notifications()->update();
}
}