, ]); } private function createDateTimeField(CustomFieldEntity $customField): Field { $factory = function (SubscriberPayload $payload) use ($customField) { return $this->getDateTimeValue($customField, $this->getCustomFieldValue($payload, $customField) ?? ''); }; return $this->createField($customField, Field::TYPE_DATETIME, $factory); } private function createYearField(CustomFieldEntity $customField): Field { $factory = function (SubscriberPayload $payload) use ($customField) { $value = $this->getDateTimeValue($customField, $this->getCustomFieldValue($payload, $customField) ?? ''); return $value ? (int)$value->format('Y') : null; }; return $this->createField($customField, Field::TYPE_INTEGER, $factory); } private function createMonthField(CustomFieldEntity $customField): Field { $factory = function (SubscriberPayload $payload) use ($customField) { $value = $this->getDateTimeValue($customField, $this->getCustomFieldValue($payload, $customField) ?? ''); return $value ? (int)$value->format('n') : null; }; return $this->createField($customField, Field::TYPE_ENUM, $factory, [ 'options' => array_map(function (int $value) { return ['id' => $value, 'name' => $this->wordPress->getWpLocale()->get_month($value)]; }, range(1, 12)), ]); } private function createDayField(CustomFieldEntity $customField): Field { $factory = function (SubscriberPayload $payload) use ($customField) { $value = $this->getDateTimeValue($customField, $this->getCustomFieldValue($payload, $customField) ?? ''); return $value ? (int)$value->format('j') : null; }; return $this->createField($customField, Field::TYPE_ENUM, $factory, [ 'options' => array_map(function (int $value) { return ['id' => $value, 'name' => "$value"]; }, range(1, 31)), ]); } private function getCustomFieldValue(SubscriberPayload $payload, CustomFieldEntity $customField): ?string { $subscriberCustomField = $payload->getSubscriber()->getSubscriberCustomFields()->filter( function (SubscriberCustomFieldEntity $subscriberCustomField) use ($customField) { return $subscriberCustomField->getCustomField() === $customField; } )->first() ?: null; return $subscriberCustomField ? $subscriberCustomField->getValue() : null; } private function createField(CustomFieldEntity $customField, string $type, callable $factory, array $args = []): Field { $key = 'mailpoet:subscriber:custom-field:' . $customField->getName(); $name = sprintf( // translators: %s is the name of the custom field __('Custom field: %s', 'mailpoet'), $customField->getParams()['label'] ?? $customField->getName() ); return new Field($key, $type, $name, $factory, $args); } private function getDateTimeValue(CustomFieldEntity $customField, ?string $value): ?DateTimeImmutable { $dateFormat = $customField->getParams()['date_format'] ?? null; if (!$dateFormat || !$value) { return null; } $dateString = (new DateConverter())->convertDateToDatetime($value, $dateFormat) ?: null; return $dateString ? new DateTimeImmutable($dateString, $this->wordPress->wpTimezone()) : null; } }
Fatal error: Uncaught Error: Class "MailPoet\Automation\Integrations\MailPoet\Fields\SubscriberCustomFieldsFactory" not found in /htdocs/wp-content/plugins/mailpoet/generated/FreeCachedContainer.php:1876 Stack trace: #0 /htdocs/wp-content/plugins/mailpoet/generated/FreeCachedContainer.php(2276): MailPoetGenerated\FreeCachedContainer->getMailPoetIntegrationService() #1 /htdocs/wp-content/plugins/mailpoet/vendor-prefixed/symfony/dependency-injection/Container.php(122): MailPoetGenerated\FreeCachedContainer->getInitializerService() #2 /htdocs/wp-content/plugins/mailpoet/vendor-prefixed/symfony/dependency-injection/Container.php(110): MailPoetVendor\Symfony\Component\DependencyInjection\Container->make('MailPoet\\Config...', 1) #3 /htdocs/wp-content/plugins/mailpoet/lib/DI/ContainerWrapper.php(39): MailPoetVendor\Symfony\Component\DependencyInjection\Container->get('MailPoet\\Config...') #4 /htdocs/wp-content/plugins/mailpoet/mailpoet_initializer.php(89): MailPoet\DI\ContainerWrapper->get('MailPoet\\Config...') #5 /htdocs/wp-content/plugins/mailpoet/mailpoet.php(206): require_once('/htdocs/wp-cont...') #6 /htdocs/wp-settings.php(462): include_once('/htdocs/wp-cont...') #7 /htdocs/wp-config.php(96): require_once('/htdocs/wp-sett...') #8 /htdocs/wp-load.php(50): require_once('/htdocs/wp-conf...') #9 /htdocs/wp-blog-header.php(13): require_once('/htdocs/wp-load...') #10 /htdocs/index.php(17): require('/htdocs/wp-blog...') #11 {main} thrown in /htdocs/wp-content/plugins/mailpoet/generated/FreeCachedContainer.php on line 1876