w \RuntimeException('Missing newsletter entity for statistic notification.'); } $link = $this->newsletterLinkRepository->findTopLinkForNewsletter((int)$newsletter->getId()); $sendingQueue = $newsletter->getLatestQueue(); if (!$sendingQueue instanceof SendingQueueEntity) { throw new \RuntimeException('Missing sending queue entity for statistic notification.'); } $context = $this->prepareContext($newsletter, $sendingQueue, $link); $subject = $sendingQueue->getNewsletterRenderedSubject(); return [ // translators: %s is the subject of the email. 'subject' => sprintf(_x('Stats for email %s', 'title of an automatic email containing statistics (newsletter open rate, click rate, etc)', 'mailpoet'), $subject), 'body' => [ 'html' => $this->renderer->render('emails/statsNotification.html', $context), 'text' => $this->renderer->render('emails/statsNotification.txt', $context), ], ]; } private function prepareContext(NewsletterEntity $newsletter, SendingQueueEntity $sendingQueue, NewsletterLinkEntity $link = null) { $statistics = $this->newsletterStatisticsRepository->getStatistics($newsletter); $clicked = ($statistics->getClickCount() * 100) / $statistics->getTotalSentCount(); $opened = ($statistics->getOpenCount() * 100) / $statistics->getTotalSentCount(); $machineOpened = ($statistics->getMachineOpenCount() * 100) / $statistics->getTotalSentCount(); $unsubscribed = ($statistics->getUnsubscribeCount() * 100) / $statistics->getTotalSentCount(); $bounced = ($statistics->getBounceCount() * 100) / $statistics->getTotalSentCount(); $subject = $sendingQueue->getNewsletterRenderedSubject(); $subscribersCount = $this->subscribersRepository->getTotalSubscribers(); $hasValidApiKey = $this->subscribersFeature->hasValidApiKey(); $context = [ 'subject' => $subject, 'preheader' => sprintf( // translators: %1$s is the percentage of clicks, %2$s the percentage of opens and %3$s the number of unsubscribes. _x( '%1$s%% clicks, %2$s%% opens, %3$s%% unsubscribes in a nutshell.', 'newsletter open rate, click rate and unsubscribe rate', 'mailpoet' ), number_format($clicked, 2), number_format($opened, 2), number_format($unsubscribed, 2) ), 'topLinkClicks' => 0, 'linkSettings' => WPFunctions::get()->getSiteUrl(null, '/wp-admin/admin.php?page=mailpoet-settings#basics'), 'linkStats' => WPFunctions::get()->getSiteUrl(null, '/wp-admin/admin.php?page=mailpoet-newsletters&stats=' . $newsletter->getId()), 'clicked' => $clicked, 'opened' => $opened, 'machineOpened' => $machineOpened, 'unsubscribed' => $unsubscribed, 'bounced' => $bounced, 'subscribersLimitReached' => $this->subscribersFeature->check(), 'hasValidApiKey' => $hasValidApiKey, 'subscribersLimit' => $this->subscribersFeature->getSubscribersLimit(), 'upgradeNowLink' => $hasValidApiKey ? 'https://account.mailpoet.com/orders/upgrade/' . $this->servicesChecker->generatePartialApiKey() : 'https://account.mailpoet.com/?s=' . ($subscribersCount + 1), ]; if ($link) { $context['topLinkClicks'] = $link->getTotalClicksCount(); $mappings = self::getShortcodeLinksMapping(); $context['topLink'] = isset($mappings[$link->getUrl()]) ? $mappings[$link->getUrl()] : $link->getUrl(); } return $context; } private function markTaskAsFinished(ScheduledTaskEntity $task) { $task->setStatus(ScheduledTaskEntity::STATUS_COMPLETED); $task->setProcessedAt(Carbon::createFromTimestamp(WPFunctions::get()->currentTime('timestamp'))); $task->setScheduledAt(null); $this->entityManager->flush(); } public static function getShortcodeLinksMapping() { return [ NewsletterLinkEntity::UNSUBSCRIBE_LINK_SHORT_CODE => __('Unsubscribe link', 'mailpoet'), NewsletterLinkEntity::INSTANT_UNSUBSCRIBE_LINK_SHORT_CODE => __('Unsubscribe link (without confirmation)', 'mailpoet'), '[link:subscription_manage_url]' => __('Manage subscription link', 'mailpoet'), '[link:newsletter_view_in_browser_url]' => __('View in browser link', 'mailpoet'), ]; } }
Fatal error: Uncaught Error: Class "MailPoet\Cron\Workers\StatsNotifications\Worker" not found in /htdocs/wp-content/plugins/mailpoet/lib/Cron/Workers/WorkersFactory.php:34 Stack trace: #0 /htdocs/wp-content/plugins/mailpoet/generated/FreeCachedContainer.php(2820): MailPoetGenerated\FreeCachedContainer->getWorkersFactoryService() #1 /htdocs/wp-content/plugins/mailpoet/generated/FreeCachedContainer.php(2750): MailPoetGenerated\FreeCachedContainer->getDaemonService() #2 /htdocs/wp-content/plugins/mailpoet/generated/FreeCachedContainer.php(2830): MailPoetGenerated\FreeCachedContainer->getDaemonRunService() #3 /htdocs/wp-content/plugins/mailpoet/generated/FreeCachedContainer.php(2790): MailPoetGenerated\FreeCachedContainer->getDaemonActionSchedulerRunnerService() #4 /htdocs/wp-content/plugins/mailpoet/generated/FreeCachedContainer.php(2612): MailPoetGenerated\FreeCachedContainer->getCronTriggerService() #5 /htdocs/wp-content/plugins/mailpoet/generated/FreeCachedContainer.php(2640): MailPoetGenerated\FreeCachedContainer->getHooks2Service() #6 /htdocs/wp-content/plugins/mailpoet/vendor-prefixed/symfony/dependency-injection/Container.php(122): MailPoetGenerated\FreeCachedContainer->getInitializerService() #7 /htdocs/wp-content/plugins/mailpoet/vendor-prefixed/symfony/dependency-injection/Container.php(110): MailPoetVendor\Symfony\Component\DependencyInjection\Container->make('MailPoet\\Config...', 1) #8 /htdocs/wp-content/plugins/mailpoet/lib/DI/ContainerWrapper.php(39): MailPoetVendor\Symfony\Component\DependencyInjection\Container->get('MailPoet\\Config...') #9 /htdocs/wp-content/plugins/mailpoet/mailpoet_initializer.php(89): MailPoet\DI\ContainerWrapper->get('MailPoet\\Config...') #10 /htdocs/wp-content/plugins/mailpoet/mailpoet.php(194): require_once('/htdocs/wp-cont...') #11 /htdocs/wp-settings.php(526): include_once('/htdocs/wp-cont...') #12 /htdocs/wp-config.php(85): require_once('/htdocs/wp-sett...') #13 /htdocs/wp-load.php(50): require_once('/htdocs/wp-conf...') #14 /htdocs/wp-blog-header.php(13): require_once('/htdocs/wp-load...') #15 /htdocs/index.php(17): require('/htdocs/wp-blog...') #16 {main} thrown in /htdocs/wp-content/plugins/mailpoet/lib/Cron/Workers/WorkersFactory.php on line 34