Server IP : 172.67.158.161 / Your IP : 18.217.110.145 Web Server : LiteSpeed System : Linux business53.web-hosting.com 4.18.0-553.lve.el8.x86_64 #1 SMP Mon May 27 15:27:34 UTC 2024 x86_64 User : giankuin ( 1871) PHP Version : 7.4.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /proc/self/root/proc/thread-self/root/proc/self/root/proc/self/root/proc/thread-self/root/home/giankuin/thietke365.net/wp-content/plugins/mailpoet/lib/Automation/Integrations/MailPoet/Hooks/ |
Upload File : |
<?php declare(strict_types = 1); namespace MailPoet\Automation\Integrations\MailPoet\Hooks; if (!defined('ABSPATH')) exit; use MailPoet\Automation\Engine\Data\StepRunArgs; use MailPoet\Automation\Engine\Hooks; use MailPoet\Automation\Engine\Storage\AutomationRunStorage; use MailPoet\Automation\Integrations\MailPoet\Subjects\SubscriberSubject; use MailPoet\WP\Functions; class CreateAutomationRunHook { /** @var Functions */ private $wp; private $automationRunStorage; public function __construct( Functions $wp, AutomationRunStorage $automationRunStorage ) { $this->wp = $wp; $this->automationRunStorage = $automationRunStorage; } public function init(): void { $this->wp->addAction(Hooks::AUTOMATION_RUN_CREATE, [$this, 'createAutomationRun'], 5, 2); } public function createAutomationRun(bool $result, StepRunArgs $args): bool { if (!$result) { return $result; } $automation = $args->getAutomation(); $runOnlyOnce = $automation->getMeta('mailpoet:run-once-per-subscriber'); if (!$runOnlyOnce) { return true; } $subscriberSubject = $args->getAutomationRun()->getSubjects(SubscriberSubject::KEY); if (!$subscriberSubject) { return true; } return $this->automationRunStorage->getCountByAutomationAndSubject($automation, current($subscriberSubject)) === 0; } }