Nessuna descrizione

EmailWithInvalidSegmentNotice.php 1.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. namespace MailPoet\Util\Notices;
  3. if (!defined('ABSPATH')) exit;
  4. use MailPoet\Cron\Workers\SendingQueue\SendingQueue;
  5. use MailPoet\WP\Functions as WPFunctions;
  6. use MailPoet\WP\Notice;
  7. class EmailWithInvalidSegmentNotice {
  8. const OPTION_NAME = SendingQueue::EMAIL_WITH_INVALID_SEGMENT_OPTION;
  9. /** @var WPFunctions */
  10. private $wp;
  11. public function __construct(
  12. WPFunctions $wp
  13. ) {
  14. $this->wp = $wp;
  15. }
  16. public function init($shouldDisplay) {
  17. if (!$shouldDisplay || !$this->wp->getTransient(self::OPTION_NAME)) {
  18. return;
  19. }
  20. return $this->display($this->wp->getTransient(self::OPTION_NAME));
  21. }
  22. public function disable() {
  23. $this->wp->deleteTransient(self::OPTION_NAME);
  24. }
  25. private function display($newsletterSubject) {
  26. $notice = sprintf(
  27. __('You are sending “%s“ to the deleted list. To continue sending, please restore the list. Alternatively, delete the newsletter if you no longer want to keep sending it.', 'mailpoet'),
  28. $this->wp->escHtml($newsletterSubject)
  29. );
  30. $extraClasses = 'mailpoet-dismissible-notice is-dismissible';
  31. Notice::displayError($notice, $extraClasses, self::OPTION_NAME, true);
  32. return $notice;
  33. }
  34. }