[ Avaa Bypassed ]




Upload:

Command:

hmhc3928@3.145.89.181: ~ $
<?php declare(strict_types = 1);

namespace MailPoet\Newsletter;

if (!defined('ABSPATH')) exit;


use MailPoet\Entities\NewsletterEntity;
use MailPoet\Features\FeaturesController;
use MailPoet\Services\Bridge;
use MailPoet\Settings\TrackingConfig;
use MailPoet\Validator\ValidationException;

class NewsletterValidator {

  /** @var Bridge */
  private $bridge;

  /** @var TrackingConfig */
  private $trackingConfig;

  /** @var FeaturesController */
  private $featuresController;

  public function __construct(
    Bridge $bridge,
    TrackingConfig $trackingConfig,
    FeaturesController $featuresController
  ) {
    $this->bridge = $bridge;
    $this->trackingConfig = $trackingConfig;
    $this->featuresController = $featuresController;
  }

  public function validate(NewsletterEntity $newsletterEntity): ?string {
    if (
      $this->featuresController->isSupported(FeaturesController::GUTENBERG_EMAIL_EDITOR)
      && $newsletterEntity->getWpPostId() !== null
    ) {
      // Temporarily skip validation for emails created via Gutenberg editor
      return null;
    }
    try {
      $this->validateSegments($newsletterEntity);
      $this->validateBody($newsletterEntity);
      $this->validateUnsubscribeRequirements($newsletterEntity);
      $this->validateReEngagementRequirements($newsletterEntity);
      $this->validateAutomaticLatestContentRequirements($newsletterEntity);
    } catch (ValidationException $exception) {
      return $exception->getMessage();
    }
    return null;
  }

  private function validateUnsubscribeRequirements(NewsletterEntity $newsletterEntity): void {
    if (!$this->bridge->isMailpoetSendingServiceEnabled()) {
      return;
    }
    $content = $newsletterEntity->getContent();
    $hasUnsubscribeUrl = strpos($content, '[link:subscription_unsubscribe_url]') !== false;
    $hasUnsubscribeLink = strpos($content, '[link:subscription_unsubscribe]') !== false;

    if (!$hasUnsubscribeLink && !$hasUnsubscribeUrl) {
      throw new ValidationException(__('All emails must include an "Unsubscribe" link. Add a footer widget to your email to continue.', 'mailpoet'));
    }
  }

  private function validateSegments(NewsletterEntity $newsletterEntity): void {
    if (
      $newsletterEntity->getType() !== NewsletterEntity::TYPE_NOTIFICATION
      && $newsletterEntity->getType() !== NewsletterEntity::TYPE_RE_ENGAGEMENT
    ) {
      return;
    }

    $emptySegmentsErrorMessage = __('You need to select a list to send to.', 'mailpoet');
    $segmentIds = $newsletterEntity->getSegmentIds();

    if (empty($segmentIds)) {
      throw new ValidationException($emptySegmentsErrorMessage);
    }
  }

  private function validateBody(NewsletterEntity $newsletterEntity): void {
    $emptyBodyErrorMessage = __('Poet, please add prose to your masterpiece before you send it to your followers.', 'mailpoet');
    $content = $newsletterEntity->getContent();

    if ($content === '') {
      throw new ValidationException($emptyBodyErrorMessage);
    }

    $contentBlocks = $newsletterEntity->getBody()['content']['blocks'] ?? [];
    if (count($contentBlocks) < 1) {
      throw new ValidationException($emptyBodyErrorMessage);
    }
  }

  private function validateReEngagementRequirements(NewsletterEntity $newsletterEntity): void {
    if ($newsletterEntity->getType() !== NewsletterEntity::TYPE_RE_ENGAGEMENT) {
      return;
    }

    if (strpos($newsletterEntity->getContent(), '[link:subscription_re_engage_url]') === false) {
      throw new ValidationException(__('A re-engagement email must include a link with [link:subscription_re_engage_url] shortcode.', 'mailpoet'));
    }

    if (!$this->trackingConfig->isEmailTrackingEnabled()) {
      throw new ValidationException(__('Re-engagement emails are disabled because open and click tracking is disabled in MailPoet → Settings → Advanced.', 'mailpoet'));
    }
  }

  private function validateAutomaticLatestContentRequirements(NewsletterEntity $newsletterEntity) {
    if ($newsletterEntity->getType() !== NewsletterEntity::TYPE_NOTIFICATION) {
      return;
    }
    $content = $newsletterEntity->getContent();
    if (
      strpos($content, '"type":"automatedLatestContent"') === false &&
      strpos($content, '"type":"automatedLatestContentLayout"') === false
    ) {
      throw new ValidationException(_x('Please add an “Automatic Latest Content” widget to the email from the right sidebar.', '(Please reuse the current translation used for the string “Automatic Latest Content”) This Error message is displayed when a user tries to send a “Post Notification” email without any “Automatic Latest Content” widget inside', 'mailpoet'));
    }
  }
}

Filemanager

Name Type Size Permission Actions
Editor Folder 0755
Links Folder 0755
Listing Folder 0755
Options Folder 0755
Preview Folder 0755
Renderer Folder 0755
Scheduler Folder 0755
Segment Folder 0755
Sending Folder 0755
Shortcodes Folder 0755
Statistics Folder 0755
ViewInBrowser Folder 0755
ApiDataSanitizer.php File 1.69 KB 0644
AutomatedLatestContent.php File 4.34 KB 0644
AutomaticEmailsRepository.php File 2.1 KB 0644
BlockPostQuery.php File 5.9 KB 0644
NewsletterCoupon.php File 1.08 KB 0644
NewsletterDeleteController.php File 6.85 KB 0644
NewsletterHtmlSanitizer.php File 2.94 KB 0644
NewsletterPostsRepository.php File 1.01 KB 0644
NewsletterSaveController.php File 17.11 KB 0644
NewsletterValidator.php File 4.59 KB 0644
NewslettersRepository.php File 21.2 KB 0644
Url.php File 2.27 KB 0644
index.php File 6 B 0644