REDROOM
PHP 8.2.31
Path:
Logout
Edit File
Size: 2.39 KB
Close
/home/nshryvcy/himaltourism.com/wp-content/plugins/mailpoet/lib/Newsletter/Renderer/Blocks/AutomatedLatestContentBlock.php
Text
Base64
<?php // phpcs:ignore SlevomatCodingStandard.TypeHints.DeclareStrictTypes.DeclareStrictTypesMissing namespace MailPoet\Newsletter\Renderer\Blocks; if (!defined('ABSPATH')) exit; use MailPoet\Entities\NewsletterEntity; use MailPoet\Entities\NewsletterPostEntity; use MailPoet\Newsletter\AutomatedLatestContent; use MailPoet\Newsletter\BlockPostQuery; use MailPoet\Newsletter\NewsletterPostsRepository; class AutomatedLatestContentBlock { /** * Cache for rendered posts in newsletter. * Used to prevent duplicate post in case a newsletter contains 2 ALC blocks * @var array */ public $renderedPostsInNewsletter; /** @var AutomatedLatestContent */ private $ALC; /** @var NewsletterPostsRepository */ private $newsletterPostsRepository; public function __construct( NewsletterPostsRepository $newsletterPostsRepository, AutomatedLatestContent $ALC ) { $this->renderedPostsInNewsletter = []; $this->ALC = $ALC; $this->newsletterPostsRepository = $newsletterPostsRepository; } public function render(NewsletterEntity $newsletter, $args) { $newerThanTimestamp = false; $newsletterId = false; if ($newsletter->getType() === NewsletterEntity::TYPE_NOTIFICATION_HISTORY) { $parent = $newsletter->getParent(); if ($parent instanceof NewsletterEntity) { $newsletterId = $parent->getId(); $lastPost = $this->newsletterPostsRepository->findOneBy(['newsletter' => $parent], ['createdAt' => 'desc']); if ($lastPost instanceof NewsletterPostEntity) { $newerThanTimestamp = $lastPost->getCreatedAt(); } } } $postsToExclude = $this->getRenderedPosts((int)$newsletterId); $query = new BlockPostQuery([ 'args' => $args, 'postsToExclude' => $postsToExclude, 'newsletterId' => $newsletterId, 'newerThanTimestamp' => $newerThanTimestamp, 'dynamic' => true, ]); $aLCPosts = $this->ALC->getPosts($query); foreach ($aLCPosts as $post) { $postsToExclude[] = $post->ID; } $this->setRenderedPosts((int)$newsletterId, $postsToExclude); return $this->ALC->transformPosts($args, $aLCPosts); } private function getRenderedPosts(int $newsletterId) { return $this->renderedPostsInNewsletter[$newsletterId] ?? []; } private function setRenderedPosts(int $newsletterId, array $posts) { return $this->renderedPostsInNewsletter[$newsletterId] = $posts; } }
Save
Close
Exit & Reset
Text mode: syntax highlighting auto-detects file type.
Directory Contents
Dirs: 0 × Files: 14
Delete Selected
Select All
Select None
Sort:
Name
Size
Modified
Enable drag-to-move
Name
Size
Perms
Modified
Actions
AbandonedCartContent.php
2.34 KB
lrw-r--r--
2023-04-04 05:35:40
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
AutomatedLatestContentBlock.php
2.39 KB
lrw-r--r--
2023-04-04 05:35:40
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
Button.php
3.40 KB
lrw-r--r--
2023-04-04 05:35:40
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
Coupon.php
4.13 KB
lrw-r--r--
2023-04-04 05:35:40
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
Divider.php
1.69 KB
lrw-r--r--
2023-04-04 05:35:40
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
Footer.php
1.92 KB
lrw-r--r--
2023-04-04 05:35:40
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
Header.php
1.92 KB
lrw-r--r--
2023-04-04 05:35:40
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
Image.php
3.01 KB
lrw-r--r--
2023-04-04 05:35:40
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
index.php
0 B
lrw-r--r--
2023-04-04 05:35:40
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
Placeholder.php
676 B
lrw-r--r--
2023-04-04 05:35:40
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
Renderer.php
4.26 KB
lrw-r--r--
2023-04-04 05:35:40
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
Social.php
1.46 KB
lrw-r--r--
2023-04-04 05:35:40
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
Spacer.php
701 B
lrw-r--r--
2023-04-04 05:35:40
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
Text.php
6.83 KB
lrw-r--r--
2023-04-04 05:35:40
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
Zip Selected
If ZipArchive is unavailable, a
.tar
will be created (no compression).