lue); } // other conditions if (!is_string($filterValue) || !$value instanceof DateTimeInterface) { return false; } $datetime = $this->convertToLocalTimezone($value); switch ($condition) { case 'before': $ref = DateTimeImmutable::createFromFormat(self::FORMAT_DATETIME, $filterValue, $this->localTimezone); return $ref && $datetime < $ref; case 'after': $ref = DateTimeImmutable::createFromFormat(self::FORMAT_DATETIME, $filterValue, $this->localTimezone); return $ref && $datetime > $ref; case 'on': return $datetime->format(self::FORMAT_DATE) === $filterValue; case 'not-on': return $datetime->format(self::FORMAT_DATE) !== $filterValue; default: return false; } } /** @param mixed $value */ private function matchesSet(string $condition, $value): bool { switch ($condition) { case self::CONDITION_IS_SET: return $value !== null; case self::CONDITION_IS_NOT_SET: return $value === null; default: return false; } } /** * @param mixed $filterValue * @param mixed $value */ private function matchesInTheLast(string $condition, $filterValue, $value): bool { if (!is_array($filterValue) || !isset($filterValue['number']) || !isset($filterValue['unit']) || !$value instanceof DateTimeInterface) { return false; } $number = $filterValue['number']; $unit = $filterValue['unit']; if (!is_integer($number) || !in_array($unit, ['days', 'weeks', 'months'], true)) { return false; } $now = new DateTimeImmutable('now', $this->localTimezone); $ref = $now->modify("-$number $unit"); $matches = $ref <= $value && $value <= $now; return $condition === self::CONDITION_IN_THE_LAST ? $matches : !$matches; } /** * @param mixed $filterValue * @param mixed $value */ private function matchesOnTheDaysOfTheWeek($filterValue, $value): bool { if (!is_array($filterValue) || !$value instanceof DateTimeInterface) { return false; } foreach ($filterValue as $day) { if (!is_integer($day) || $day < 0 || $day > 6) { return false; } } $date = $this->convertToLocalTimezone($value); $day = (int)$date->format('w'); return in_array($day, $filterValue, true); } private function convertToLocalTimezone(DateTimeInterface $datetime): DateTimeImmutable { $value = DateTimeImmutable::createFromFormat('U', (string)$datetime->getTimestamp(), $this->localTimezone); if (!$value) { throw new InvalidStateException('Failed to convert datetime to WP timezone'); } return $value; } }
Fatal error: Uncaught Error: Class "MailPoet\Automation\Integrations\Core\Filters\DateTimeFilter" not found in /htdocs/wp-content/plugins/mailpoet/lib/Automation/Integrations/Core/CoreIntegration.php:42 Stack trace: #0 /htdocs/wp-content/plugins/mailpoet/lib/Automation/Engine/Engine.php(76): MailPoet\Automation\Integrations\Core\CoreIntegration->register(Object(MailPoet\Automation\Engine\Registry)) #1 /htdocs/wp-content/plugins/mailpoet/lib/Config/Initializer.php(377): MailPoet\Automation\Engine\Engine->initialize() #2 /htdocs/wp-includes/class-wp-hook.php(324): MailPoet\Config\Initializer->initialize('') #3 /htdocs/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters(NULL, Array) #4 /htdocs/wp-includes/plugin.php(517): WP_Hook->do_action(Array) #5 /htdocs/wp-settings.php(695): do_action('init') #6 /htdocs/wp-config.php(89): require_once('/htdocs/wp-sett...') #7 /htdocs/wp-load.php(50): require_once('/htdocs/wp-conf...') #8 /htdocs/wp-blog-header.php(13): require_once('/htdocs/wp-load...') #9 /htdocs/index.php(17): require('/htdocs/wp-blog...') #10 {main} thrown in /htdocs/wp-content/plugins/mailpoet/lib/Automation/Integrations/Core/CoreIntegration.php on line 42