| Server IP : 8.134.250.228 / Your IP : 216.73.216.70 Web Server : Apache System : Linux iZ7xv33p9e9ivk7yhmj7ibZ 5.10.134-18.al8.x86_64 #1 SMP Fri Dec 13 16:56:53 CST 2024 x86_64 User : www ( 1000) PHP Version : 8.0.26 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 : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /www/wwwroot/www.gobluemade.com/wp-content/plugins/wpforms-lite/src/Tasks/Actions/ |
Upload File : |
<?php
namespace WPForms\Tasks\Actions;
use WPForms\Tasks\Task;
/**
* Class PurgeSpamTask.
*
* @since 1.9.1
*/
class PurgeSpamTask extends Task {
/**
* Action name for this task.
*
* @since 1.9.1
*/
const ACTION = 'wpforms_process_purge_spam';
/**
* Interval in seconds.
*
* @since 1.9.1
*
* @var int
*/
private $interval;
/**
* Tasks class instance.
*
* @since 1.9.1
*
* @var Tasks
*/
private $tasks;
/**
* Log title.
*
* @since 1.9.1
*
* @var string
*/
protected $log_title = 'Purge Spam';
/**
* Class constructor.
*
* @since 1.9.1
*/
public function __construct() {
parent::__construct( self::ACTION );
$this->init();
$this->hooks();
}
/**
* Init.
*
* @since 1.9.1
*/
public function init() {
/**
* Filter the interval for the purge spam task, in seconds.
*
* @since 1.9.1
*
* @param int $interval Interval in seconds.
*
* @return int
*/
$this->interval = (int) apply_filters( 'wpforms_tasks_actions_purge_spam_task_interval', DAY_IN_SECONDS );
$this->tasks = wpforms()->obj( 'tasks' );
// Do not add a new one if scheduled.
if ( $this->tasks->is_scheduled( self::ACTION ) !== false ) {
if ( $this->interval <= 0 ) {
$this->cancel();
}
return;
}
$this->add_scan_task();
}
/**
* Add hooks.
*
* @since 1.9.1
*/
public function hooks() {
add_action( self::ACTION, [ $this, 'process' ] );
}
/**
* Add a new task.
*
* @since 1.9.1
*/
private function add_scan_task() {
if ( $this->interval <= 0 ) {
return;
}
$this->tasks->create( self::ACTION )
->recurring( time(), $this->interval )
->params()
->register();
}
/**
* Purge spam action.
*
* @since 1.9.1
*/
public function process() {
$entry_obj = wpforms()->obj( 'entry' );
if ( ! $entry_obj ) {
return;
}
$entry_obj->purge_spam();
$this->log( 'Purge spam completed.' );
}
}