diff --git a/.github/no-response.yml b/.github/no-response.yml new file mode 100644 index 0000000..3d0bde5 --- /dev/null +++ b/.github/no-response.yml @@ -0,0 +1,13 @@ +# Configuration for probot-no-response - https://github.com/probot/no-response + +# Number of days of inactivity before an Issue is closed for lack of response +daysUntilClose: 7 +# Label requiring a response +responseRequiredLabel: waiting-customer-response +# Comment to post when closing an Issue for lack of response. Set to `false` to disable +closeComment: > + This issue has been automatically closed because there has been no response + to our request for more information from the original author. With only the + information that is currently in the issue, we don't have enough information + to take action. Please reach out if you have or find the answers we need so + that we can investigate further. \ No newline at end of file diff --git a/Block/Adminhtml/System/Config/Button.php b/Block/Adminhtml/System/Config/Button.php index 13ee338..f31a1a3 100644 --- a/Block/Adminhtml/System/Config/Button.php +++ b/Block/Adminhtml/System/Config/Button.php @@ -38,7 +38,8 @@ class Button extends Field /** * Unset scope * - * @param \Magento\Framework\Data\Form\Element\AbstractElement $element + * @param AbstractElement $element + * * @return string */ public function render(AbstractElement $element) @@ -51,7 +52,8 @@ public function render(AbstractElement $element) /** * Get the button and scripts contents * - * @param \Magento\Framework\Data\Form\Element\AbstractElement $element + * @param AbstractElement $element + * * @return string */ protected function _getElementHtml(AbstractElement $element) @@ -67,4 +69,4 @@ protected function _getElementHtml(AbstractElement $element) return $this->_toHtml(); } -} \ No newline at end of file +} diff --git a/Block/Adminhtml/System/Config/Template.php b/Block/Adminhtml/System/Config/Template.php index 8417692..508c9e2 100644 --- a/Block/Adminhtml/System/Config/Template.php +++ b/Block/Adminhtml/System/Config/Template.php @@ -24,6 +24,7 @@ use Magento\Backend\Block\Template\Context; use Magento\Config\Block\System\Config\Form\Field; use Magento\Framework\Data\Form\Element\AbstractElement; +use Magento\Framework\Exception\FileSystemException; use Mageplaza\BetterPopup\Helper\Data; /** @@ -38,12 +39,13 @@ class Template extends Field protected $_template = 'Mageplaza_BetterPopup::system/config/template.phtml'; /** - * @var \Mageplaza\BetterPopup\Helper\Data + * @var Data */ protected $_helperData; /** * Template constructor. + * * @param Context $context * @param Data $helperData * @param array $data @@ -52,8 +54,7 @@ public function __construct( Context $context, Data $helperData, array $data = [] - ) - { + ) { $this->_helperData = $helperData; parent::__construct($context, $data); @@ -61,13 +62,14 @@ public function __construct( /** * @param AbstractElement $element + * * @return string - * @throws \Magento\Framework\Exception\FileSystemException + * @throws FileSystemException */ protected function _getElementHtml(AbstractElement $element) { $originalData = $element->getOriginalData(); - $buttonLabel = !empty($originalData['button_label']) ? $originalData['button_label'] : ''; + $buttonLabel = !empty($originalData['button_label']) ? $originalData['button_label'] : ''; $this->addData( [ 'button_label' => __($buttonLabel), @@ -82,7 +84,7 @@ protected function _getElementHtml(AbstractElement $element) /** * @return array - * @throws \Magento\Framework\Exception\FileSystemException + * @throws FileSystemException */ private function getOptionTemplate() { @@ -127,4 +129,4 @@ private function getOptionTemplate() return $options; } -} \ No newline at end of file +} diff --git a/Block/Adminhtml/System/FeatureDisplay.php b/Block/Adminhtml/System/FeatureDisplay.php index 13bd71f..80c4b54 100644 --- a/Block/Adminhtml/System/FeatureDisplay.php +++ b/Block/Adminhtml/System/FeatureDisplay.php @@ -31,7 +31,8 @@ class FeatureDisplay extends Field { /** - * @param \Magento\Framework\Data\Form\Element\AbstractElement $element + * @param AbstractElement $element + * * @return string */ protected function _getElementHtml(AbstractElement $element) diff --git a/Block/Dashboard/Newsletter.php b/Block/Dashboard/Newsletter.php index cfa421c..9a33010 100644 --- a/Block/Dashboard/Newsletter.php +++ b/Block/Dashboard/Newsletter.php @@ -21,6 +21,7 @@ namespace Mageplaza\BetterPopup\Block\Dashboard; +use Magento\Framework\Phrase; use Mageplaza\BetterPopup\Block\Subscriber; /** @@ -35,10 +36,10 @@ class Newsletter extends Subscriber protected $_template = 'dashboard/newsletter.phtml'; /** - * @return \Magento\Framework\Phrase|string + * @return Phrase|string */ public function getTitle() { return __('Subscribers'); } -} \ No newline at end of file +} diff --git a/Block/Email/Template.php b/Block/Email/Template.php index 62175d7..6c7cdda 100644 --- a/Block/Email/Template.php +++ b/Block/Email/Template.php @@ -36,7 +36,7 @@ class Template extends Subscriber */ public function getListEmailSubscriberWeek() { - $listEmail = []; + $listEmail = []; $subscribersCollection = $this->getSubscriberInWeek($this->_helperData->getStoreId()); foreach ($subscribersCollection as $item) { $listEmail[] = $item->getData('subscriber_email'); @@ -56,4 +56,4 @@ public function getCurrentTime() return date('d M Y', strtotime($date)); } -} \ No newline at end of file +} diff --git a/Block/Popup.php b/Block/Popup.php index 47b1609..5867fc3 100644 --- a/Block/Popup.php +++ b/Block/Popup.php @@ -23,6 +23,7 @@ use Magento\Catalog\Block\Product\AbstractProduct; use Magento\Catalog\Block\Product\Context; +use Magento\Framework\Phrase; use Magento\Newsletter\Model\ResourceModel\Subscriber\CollectionFactory; use Magento\Widget\Block\BlockInterface; use Mageplaza\BetterPopup\Helper\Data as HelperData; @@ -37,17 +38,18 @@ class Popup extends AbstractProduct implements BlockInterface { /** - * @var \Mageplaza\BetterPopup\Helper\Data + * @var HelperData */ protected $_helperData; /** - * @var \Magento\Newsletter\Model\ResourceModel\Subscriber\CollectionFactory + * @var CollectionFactory */ protected $_subscriberCollectionFactory; /** * Popup constructor. + * * @param Context $context * @param HelperData $helperData * @param CollectionFactory $subscriberCollectionFactory @@ -58,9 +60,8 @@ public function __construct( HelperData $helperData, CollectionFactory $subscriberCollectionFactory, array $data = [] - ) - { - $this->_helperData = $helperData; + ) { + $this->_helperData = $helperData; $this->_subscriberCollectionFactory = $subscriberCollectionFactory; parent::__construct($context, $data); @@ -113,11 +114,7 @@ public function getTextColor() */ public function isFullScreen() { - if ($this->_helperData->getWhatToShowConfig('responsive') == Responsive::FULLSCREEN_POPUP) { - return true; - } - - return false; + return (int) $this->_helperData->getWhatToShowConfig('responsive') === Responsive::FULLSCREEN_POPUP; } /** @@ -127,11 +124,7 @@ public function isFullScreen() */ public function isShowFireworks() { - if ($this->_helperData->getWhatToShowConfig('popup_success/enabled_fireworks')) { - return true; - } - - return false; + return $this->_helperData->getWhatToShowConfig('popup_success/enabled_fireworks'); } /** @@ -157,7 +150,7 @@ public function getLocationFloatButton() /** * Get Float button label * - * @return \Magento\Framework\Phrase + * @return Phrase */ public function getFloatLabel() { @@ -173,7 +166,7 @@ public function getFloatLabel() */ public function getPopupAppear() { - return $this->_helperData->getWhenToShowConfig('popup_appear'); + return (int) $this->_helperData->getWhenToShowConfig('popup_appear'); } /** @@ -183,7 +176,7 @@ public function getPopupAppear() */ public function getDelayConfig() { - if ($this->getPopupAppear() == Appear::AFTER_X_SECONDS) { + if ($this->getPopupAppear() === Appear::AFTER_X_SECONDS) { return $this->_helperData->getWhenToShowConfig('delay'); } @@ -197,11 +190,7 @@ public function getDelayConfig() */ public function isExitIntent() { - if ($this->getPopupAppear() == Appear::EXIT_INTENT) { - return true; - } - - return false; + return $this->getPopupAppear() === Appear::EXIT_INTENT; } /** @@ -211,7 +200,7 @@ public function isExitIntent() */ public function getCookieConfig() { - $cookieDays = (int)$this->_helperData->getWhenToShowConfig('cookieExp'); + $cookieDays = (int) $this->_helperData->getWhenToShowConfig('cookieExp'); return ($cookieDays !== null) ? $cookieDays : 30; } @@ -235,7 +224,7 @@ public function getPopupContent() { $htmlConfig = $this->_helperData->getWhatToShowConfig('html_content'); - $search = [ + $search = [ '{{form_url}}', '{{url_loader}}', '{{email_icon_url}}', @@ -262,9 +251,7 @@ public function getPopupContent() $this->getViewFileUrl('Mageplaza_BetterPopup::images/template5/img-email.png') ]; - $html = str_replace($search, $replace, $htmlConfig); - - return $html; + return str_replace($search, $replace, $htmlConfig); } /** @@ -275,10 +262,10 @@ public function getPopupContent() public function checkIncludePages() { $fullActionName = $this->getRequest()->getFullActionName(); - $arrayPages = explode("\n", $this->_helperData->getWhereToShowConfig('include_pages')); - $includePages = array_map('trim', $arrayPages); + $arrayPages = explode("\n", $this->_helperData->getWhereToShowConfig('include_pages')); + $includePages = array_map('trim', $arrayPages); - return in_array($fullActionName, $includePages); + return in_array($fullActionName, $includePages, true); } /** @@ -293,9 +280,9 @@ public function checkIncludePaths() if ($pathsConfig) { $arrayPaths = explode("\n", $pathsConfig); - $pathsUrl = array_map('trim', $arrayPaths); + $pathsUrl = array_map('trim', $arrayPaths); foreach ($pathsUrl as $path) { - if (strpos($currentPath, $path) !== false) { + if ($path && strpos($currentPath, $path) !== false) { return true; } } @@ -312,10 +299,10 @@ public function checkIncludePaths() public function checkExcludePages() { $fullActionName = $this->getRequest()->getFullActionName(); - $arrayPages = explode("\n", $this->_helperData->getWhereToShowConfig('exclude_pages')); - $includePages = array_map('trim', $arrayPages); + $arrayPages = explode("\n", $this->_helperData->getWhereToShowConfig('exclude_pages')); + $includePages = array_map('trim', $arrayPages); - return !in_array($fullActionName, $includePages); + return !in_array($fullActionName, $includePages, true); } /** @@ -330,7 +317,7 @@ public function checkExcludePaths() if ($pathsConfig) { $arrayPaths = explode("\n", $pathsConfig); - $pathsUrl = array_map('trim', $arrayPaths); + $pathsUrl = array_map('trim', $arrayPaths); foreach ($pathsUrl as $path) { if (strpos($currentPath, $path) !== false) { @@ -370,8 +357,8 @@ public function checkExclude() public function isManuallyInsert() { return $this->_helperData->isEnabled() - && $this->_helperData->getWhereToShowConfig('which_page_to_show') == PageToShow::MANUALLY_INSERT - && $this->checkExclude(); + && (int) $this->_helperData->getWhereToShowConfig('which_page_to_show') === PageToShow::MANUALLY_INSERT + && $this->checkExclude(); } /** @@ -385,11 +372,11 @@ public function checkPagesToShow() $config = $this->_helperData->getWhereToShowConfig('which_page_to_show'); switch ($config) { - case PageToShow::SPECIFIC_PAGES : + case PageToShow::SPECIFIC_PAGES: return ($this->checkInclude() && $this->checkExclude()); - case PageToShow::ALL_PAGES : + case PageToShow::ALL_PAGES: return $this->checkExclude(); - case PageToShow::MANUALLY_INSERT : + case PageToShow::MANUALLY_INSERT: return false; } } @@ -406,9 +393,9 @@ public function getAjaxData() { $params = [ 'url' => $this->getUrl('betterpopup/ajax/success'), - 'isScroll' => $this->getPopupAppear() == Appear::AFTER_SCROLL_DOWN, + 'isScroll' => $this->getPopupAppear() === Appear::AFTER_SCROLL_DOWN, 'afterSeconds' => [ - 'isAfterSeconds' => $this->getPopupAppear() == Appear::AFTER_X_SECONDS, + 'isAfterSeconds' => $this->getPopupAppear() === Appear::AFTER_X_SECONDS, 'delay' => $this->getDelayConfig() ], 'percentage' => $this->getPercentageScroll(), @@ -440,4 +427,4 @@ public function getFormActionUrl() { return $this->getUrl('newsletter/subscriber/new', ['_secure' => true]); } -} \ No newline at end of file +} diff --git a/Block/Subscriber.php b/Block/Subscriber.php index 12b8f1e..dd0969e 100644 --- a/Block/Subscriber.php +++ b/Block/Subscriber.php @@ -23,6 +23,7 @@ use Magento\Framework\Stdlib\DateTime\DateTime; use Magento\Framework\View\Element\Template; +use Magento\Newsletter\Model\ResourceModel\Subscriber\Collection; use Magento\Newsletter\Model\ResourceModel\Subscriber\CollectionFactory; use Magento\Widget\Block\BlockInterface; use Mageplaza\BetterPopup\Helper\Data as HelperData; @@ -34,7 +35,7 @@ class Subscriber extends Template implements BlockInterface { /** - * @var \Magento\Newsletter\Model\ResourceModel\Subscriber\CollectionFactory + * @var CollectionFactory */ protected $_subscriberCollectionFactory; @@ -44,12 +45,13 @@ class Subscriber extends Template implements BlockInterface protected $_getDayDate; /** - * @var \Mageplaza\BetterPopup\Helper\Data + * @var HelperData */ protected $_helperData; /** * Subscriber constructor. + * * @param Template\Context $context * @param HelperData $helperData * @param CollectionFactory $subscriberCollectionFactory @@ -62,19 +64,19 @@ public function __construct( CollectionFactory $subscriberCollectionFactory, DateTime $getDayDate, array $data = [] - ) - { + ) { parent::__construct($context, $data); - $this->_helperData = $helperData; + $this->_helperData = $helperData; $this->_subscriberCollectionFactory = $subscriberCollectionFactory; - $this->_getDayDate = $getDayDate; + $this->_getDayDate = $getDayDate; } /** * @param $from * @param $to - * @return \Magento\Newsletter\Model\ResourceModel\Subscriber\Collection + * + * @return Collection */ public function getSubscriberCollection($from, $to, $storeId) { @@ -88,12 +90,12 @@ public function getSubscriberCollection($from, $to, $storeId) /** * Get Subscriber Collection today * - * @return \Magento\Newsletter\Model\ResourceModel\Subscriber\Collection + * @return Collection */ public function getSubscriberToday() { - $form = $this->_getDayDate->date(null, '0:0:0'); - $to = $this->_getDayDate->date(null, '23:59:59'); + $form = $this->_getDayDate->date(null, '0:0:0'); + $to = $this->_getDayDate->date(null, '23:59:59'); $collection = $this->getSubscriberCollection($form, $to, $this->_helperData->getStoreId()); return $collection; @@ -102,32 +104,31 @@ public function getSubscriberToday() /** * Get Subscriber Collection in a week * - * @return \Magento\Newsletter\Model\ResourceModel\Subscriber\Collection + * @param $storeId + * + * @return Collection */ public function getSubscriberInWeek($storeId = null) { - $now = date("Y-m-d h:i:s"); - $to = strtotime('+1 day', strtotime($now)); - $to = date('Y-m-d h:i:s', $to); - $from = strtotime('-7 day', strtotime($now)); - $from = date('Y-m-d h:i:s', $from); - $collection = $this->getSubscriberCollection($from, $to, $storeId); + $now = date('Y-m-d h:i:s'); + $to = date('Y-m-d h:i:s', strtotime('+1 day')); + $from = strtotime('-7 day', strtotime($now)); + $from = date('Y-m-d h:i:s', $from); - return $collection; + return $this->getSubscriberCollection($from, $to, $storeId); } /** * Get Subscriber Collection in a month * - * @return \Magento\Newsletter\Model\ResourceModel\Subscriber\Collection + * @return Collection */ public function getSubscriberInMonth() { - $now = date("Y-m-d h:i:s"); - $to = strtotime('+1 day', strtotime($now)); - $to = date('Y-m-d h:i:s', $to); - $from = strtotime('-30 day', strtotime($now)); - $from = date('Y-m-d h:i:s', $from); + $now = date('Y-m-d h:i:s'); + $to = date('Y-m-d h:i:s', strtotime('+1 day')); + $from = strtotime('-30 day', strtotime($now)); + $from = date('Y-m-d h:i:s', $from); $collection = $this->getSubscriberCollection($from, $to, $this->_helperData->getStoreId()); return $collection; @@ -136,13 +137,15 @@ public function getSubscriberInMonth() /** * Get Unsubscribers Collection in the week * - * @return \Magento\Newsletter\Model\ResourceModel\Subscriber\Collection + * @param $storeId + * + * @return mixed */ public function getUnSubscriberCollection($storeId) { - $to = date("Y-m-d h:i:s"); - $from = strtotime('-7 day', strtotime($to)); - $from = date('Y-m-d h:i:s', $from); + $to = date('Y-m-d h:i:s'); + $from = strtotime('-7 day', strtotime($to)); + $from = date('Y-m-d h:i:s', $from); $unSubscribersCollection = $this->_subscriberCollectionFactory->create() ->addFieldToFilter('subscriber_status', \Magento\Newsletter\Model\Subscriber::STATUS_UNSUBSCRIBED) ->addFieldToFilter('change_status_at', ['from' => $from, 'to' => $to]) @@ -150,4 +153,4 @@ public function getUnSubscriberCollection($storeId) return $unSubscribersCollection; } -} \ No newline at end of file +} diff --git a/Block/Success.php b/Block/Success.php index f41a039..7dc74ce 100644 --- a/Block/Success.php +++ b/Block/Success.php @@ -50,8 +50,7 @@ public function getCouponCode() public function getPopupSuccessContent() { $htmlConfig = $this->_helperData->getWhatToShowConfig('popup_success/html_success_content'); - $html = str_replace('{{coupon_code}}', $this->getCouponCode(), $htmlConfig); - return $html; + return str_replace('{{coupon_code}}', $this->getCouponCode(), $htmlConfig); } -} \ No newline at end of file +} diff --git a/Controller/Adminhtml/Send/Send.php b/Controller/Adminhtml/Send/Send.php index 1dee7d7..d838799 100644 --- a/Controller/Adminhtml/Send/Send.php +++ b/Controller/Adminhtml/Send/Send.php @@ -21,8 +21,14 @@ namespace Mageplaza\BetterPopup\Controller\Adminhtml\Send; +use Exception; use Magento\Backend\App\Action; use Magento\Backend\App\Action\Context; +use Magento\Framework\App\Area; +use Magento\Framework\App\ResponseInterface; +use Magento\Framework\Controller\ResultInterface; +use Magento\Framework\Exception\LocalizedException; +use Magento\Framework\Exception\MailException; use Magento\Framework\Mail\Template\TransportBuilder; use Magento\Store\Model\StoreManagerInterface; use Mageplaza\BetterPopup\Block\Email\Template; @@ -36,7 +42,7 @@ class Send extends Action { /** - * @var \Psr\Log\LoggerInterface + * @var LoggerInterface */ protected $logger; @@ -51,17 +57,18 @@ class Send extends Action protected $_helperData; /** - * @var \Mageplaza\BetterPopup\Block\Email\Template + * @var Template */ protected $_template; /** - * @var \Magento\Framework\Mail\Template\TransportBuilder + * @var TransportBuilder */ protected $_transportBuilder; /** * Send constructor. + * * @param Context $context * @param HelperData $helperData * @param Template $template @@ -76,39 +83,42 @@ public function __construct( TransportBuilder $transportBuilder, StoreManagerInterface $storeManager, LoggerInterface $logger - ) - { + ) { parent::__construct($context); - $this->_helperData = $helperData; - $this->_template = $template; + $this->_helperData = $helperData; + $this->_template = $template; $this->_transportBuilder = $transportBuilder; - $this->_storeManager = $storeManager; - $this->logger = $logger; + $this->_storeManager = $storeManager; + $this->logger = $logger; } /** - * @return \Magento\Framework\App\ResponseInterface|\Magento\Framework\Controller\ResultInterface + * @return ResponseInterface|ResultInterface */ public function execute() { $result['status'] = false; - $toEmail = $this->_helperData->getToEmail(); + $toEmail = $this->_helperData->getToEmail(); if ($toEmail) { try { foreach ($this->_storeManager->getStores() as $store) { - $this->sendMail($store); + $isSendMail = $this->_helperData->getSendEmailConfig('isSendEmail', $store->getId()); + $isEnable = $this->_helperData->isEnabled($store->getId()); + if ($isEnable && $isSendMail) { + $this->sendMail($store); + } } - $result['status'] = true; + $result['status'] = true; $result['content'] = __('Sent successfully! Please check your email box.'); - } catch (\Exception $e) { + } catch (Exception $e) { $result['content'] = __('There is an error occurred while sending email. Please try again later.'); $this->logger->critical($e); } } else { - $result['status'] = false; + $result['status'] = false; $result['content'] = __('Please enter email and save config'); } @@ -119,7 +129,10 @@ public function execute() * Send Mail * * @param $store - * @return null + * + * @return |null + * @throws LocalizedException + * @throws MailException */ public function sendMail($store) { @@ -128,12 +141,12 @@ public function sendMail($store) return null; } - $subscriber = $this->_template->getSubscriberInWeek($store->getId())->getSize(); + $subscriber = $this->_template->getSubscriberInWeek($store->getId())->getSize(); $unSubscriber = $this->_template->getunSubscriberCollection($store->getId())->getSize(); - $currentTime = $this->_template->getCurrentTime(); - $store_name = $store->getName(); + $currentTime = $this->_template->getCurrentTime(); + $store_name = $store->getName(); - $vars = [ + $vars = [ 'mp_subscriber' => $subscriber, 'mp_unSubscriber' => $unSubscriber, 'currentTime' => $currentTime, @@ -142,7 +155,7 @@ public function sendMail($store) $transport = $this->_transportBuilder ->setTemplateIdentifier('mageplaza_betterpopup_template') ->setTemplateOptions([ - 'area' => \Magento\Framework\App\Area::AREA_FRONTEND, + 'area' => Area::AREA_FRONTEND, 'store' => $store->getId() ]) ->setFrom('general') @@ -152,8 +165,8 @@ public function sendMail($store) try { $transport->sendMessage(); - } catch (\Exception $e) { + } catch (Exception $e) { $this->logger->error($e->getMessage()); } } -} \ No newline at end of file +} diff --git a/Controller/Ajax/Success.php b/Controller/Ajax/Success.php index d34d192..0d4c3ee 100644 --- a/Controller/Ajax/Success.php +++ b/Controller/Ajax/Success.php @@ -23,7 +23,10 @@ use Magento\Backend\App\Action\Context; use Magento\Framework\App\Action\Action; +use Magento\Framework\App\ResponseInterface; +use Magento\Framework\Controller\Result\Json; use Magento\Framework\Controller\Result\JsonFactory; +use Magento\Framework\Controller\ResultInterface; use Magento\Framework\View\Result\LayoutFactory; /** @@ -33,17 +36,18 @@ class Success extends Action { /** - * @var \Magento\Framework\View\Result\LayoutFactory + * @var LayoutFactory */ protected $resultLayoutFactory; /** - * @var \Magento\Framework\Controller\Result\JsonFactory + * @var JsonFactory */ protected $resultJsonFactory; /** * Success constructor. + * * @param Context $context * @param JsonFactory $resultJsonFactory * @param LayoutFactory $resultLayoutFactory @@ -52,26 +56,25 @@ public function __construct( Context $context, JsonFactory $resultJsonFactory, LayoutFactory $resultLayoutFactory - ) - { + ) { $this->resultLayoutFactory = $resultLayoutFactory; - $this->resultJsonFactory = $resultJsonFactory; + $this->resultJsonFactory = $resultJsonFactory; parent::__construct($context); } /** - * @return \Magento\Framework\App\ResponseInterface|\Magento\Framework\Controller\Result\Json|\Magento\Framework\Controller\ResultInterface + * @return ResponseInterface|Json|ResultInterface */ public function execute() { - $result = $this->resultJsonFactory->create(); + $result = $this->resultJsonFactory->create(); $resultLayout = $this->resultLayoutFactory->create(); - $blockHtml = $resultLayout->getLayout() - ->createBlock('Mageplaza\BetterPopup\Block\Success') + $blockHtml = $resultLayout->getLayout() + ->createBlock(\Mageplaza\BetterPopup\Block\Success::class) ->toHtml(); $result->setData(['success' => $blockHtml]); return $result; } -} \ No newline at end of file +} diff --git a/Cron/SendMail.php b/Cron/SendMail.php index 8ae3dc3..9a1cee0 100644 --- a/Cron/SendMail.php +++ b/Cron/SendMail.php @@ -21,6 +21,8 @@ namespace Mageplaza\BetterPopup\Cron; +use Magento\Framework\Exception\LocalizedException; +use Magento\Framework\Exception\MailException; use Magento\Store\Model\StoreManagerInterface; use Mageplaza\BetterPopup\Controller\Adminhtml\Send\Send; use Mageplaza\BetterPopup\Helper\Data; @@ -32,22 +34,23 @@ class SendMail { /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var StoreManagerInterface */ protected $_storeManager; /** - * @var \Mageplaza\BetterPopup\Helper\Data + * @var Data */ protected $_helperData; /** - * @var \Mageplaza\BetterPopup\Controller\Adminhtml\Send\Send + * @var Send */ protected $_send; /** * SendMail constructor. + * * @param Data $helperData * @param Send $send * @param StoreManagerInterface $storeManager @@ -56,15 +59,15 @@ public function __construct( Data $helperData, Send $send, StoreManagerInterface $storeManager - ) - { - $this->_helperData = $helperData; - $this->_send = $send; + ) { + $this->_helperData = $helperData; + $this->_send = $send; $this->_storeManager = $storeManager; } /** - * @return void + * @throws LocalizedException + * @throws MailException */ public function execute() { @@ -74,4 +77,4 @@ public function execute() } } } -} \ No newline at end of file +} diff --git a/Helper/Data.php b/Helper/Data.php index 74283cb..84daa8c 100644 --- a/Helper/Data.php +++ b/Helper/Data.php @@ -23,6 +23,8 @@ use Magento\Framework\App\Filesystem\DirectoryList; use Magento\Framework\App\Helper\Context; +use Magento\Framework\Exception\FileSystemException; +use Magento\Framework\Exception\NoSuchEntityException; use Magento\Framework\Filesystem; use Magento\Framework\ObjectManagerInterface; use Magento\Store\Model\StoreManagerInterface; @@ -42,12 +44,13 @@ class Data extends AbstractHelper protected $_directoryList; /** - * @var \Magento\Framework\Filesystem + * @var Filesystem */ protected $_fileSystem; /** * Data constructor. + * * @param Context $context * @param ObjectManagerInterface $objectManager * @param StoreManagerInterface $storeManager @@ -60,9 +63,8 @@ public function __construct( StoreManagerInterface $storeManager, Filesystem $filesystem, DirectoryList $directoryList - ) - { - $this->_fileSystem = $filesystem; + ) { + $this->_fileSystem = $filesystem; $this->_directoryList = $directoryList; parent::__construct($context, $objectManager, $storeManager); @@ -71,6 +73,7 @@ public function __construct( /** * @param $code * @param null $storeId + * * @return array|mixed */ public function getWhatToShowConfig($code, $storeId = null) @@ -81,6 +84,7 @@ public function getWhatToShowConfig($code, $storeId = null) /** * @param $code * @param null $storeId + * * @return array|mixed */ public function getWhereToShowConfig($code, $storeId = null) @@ -91,6 +95,7 @@ public function getWhereToShowConfig($code, $storeId = null) /** * @param $code * @param null $storeId + * * @return array|mixed */ public function getWhenToShowConfig($code, $storeId = null) @@ -101,6 +106,7 @@ public function getWhenToShowConfig($code, $storeId = null) /** * @param $code * @param null $storeId + * * @return mixed */ public function getSendEmailConfig($code, $storeId = null) @@ -109,7 +115,7 @@ public function getSendEmailConfig($code, $storeId = null) } /** - * Is Send Email Config + * @param null $storeId * * @return mixed */ @@ -130,8 +136,10 @@ public function getToEmail() /** * Get default template path + * * @param $templateId * @param string $type + * * @return string */ public function getTemplatePath($templateId, $type = '.html') @@ -143,17 +151,21 @@ public function getTemplatePath($templateId, $type = '.html') $rootPath = $this->_directoryList->getRoot(); $currentDirArr = explode('\\', $currentDir); - if (count($currentDirArr) == 1) { + $countDir = count($currentDirArr); + if ($countDir === 1) { $currentDirArr = explode('/', $currentDir); + $countDir = count($currentDirArr); } $rootPathArr = explode('/', $rootPath); - if (count($rootPathArr) == 1) { + $countPath = count($rootPathArr); + if ($countPath === 1) { $rootPathArr = explode('\\', $rootPath); + $countPath = count($rootPathArr); } $basePath = ''; - for ($i = count($rootPathArr); $i < count($currentDirArr) - 1; $i++) { + for ($i = $countPath; $i < $countDir - 1; $i++) { $basePath .= $currentDirArr[$i] . '/'; } @@ -164,8 +176,9 @@ public function getTemplatePath($templateId, $type = '.html') /** * @param $relativePath + * * @return string - * @throws \Magento\Framework\Exception\FileSystemException + * @throws FileSystemException */ public function readFile($relativePath) { @@ -176,8 +189,9 @@ public function readFile($relativePath) /** * @param $templateId + * * @return string - * @throws \Magento\Framework\Exception\FileSystemException + * @throws FileSystemException */ public function getDefaultTemplateHtml($templateId) { @@ -185,12 +199,11 @@ public function getDefaultTemplateHtml($templateId) } /** - * Get Store Id - * * @return int + * @throws NoSuchEntityException */ public function getStoreId() { return $this->storeManager->getStore()->getId(); } -} \ No newline at end of file +} diff --git a/Model/Config/Backend/Validate.php b/Model/Config/Backend/Validate.php index 69b09a6..e8b7038 100644 --- a/Model/Config/Backend/Validate.php +++ b/Model/Config/Backend/Validate.php @@ -21,6 +21,7 @@ namespace Mageplaza\BetterPopup\Model\Config\Backend; +use Exception; use Magento\Framework\App\Config\Value; /** @@ -33,18 +34,18 @@ class Validate extends Value * Check value not null Exclude and Include * * @return Value - * @throws \Exception + * @throws Exception */ public function beforeSave() { $pageToShow = $this->getData('fieldset_data')['which_page_to_show']; - $inPage = $this->getData('fieldset_data')['include_pages']; - $inPageUrl = $this->getData('fieldset_data')['include_pages_with_url']; + $inPage = $this->getData('fieldset_data')['include_pages']; + $inPageUrl = $this->getData('fieldset_data')['include_pages_with_url']; if ($pageToShow == 1 && !($inPage || $inPageUrl)) { - throw new \Exception('Please enter the value into one of the following boxes: Include page(s) and Include Page(s) with URL contains.'); + throw new Exception(__('Please enter the value into one of the following boxes: Include page(s) and Include Page(s) with URL contains.')); } return parent::beforeSave(); } -} \ No newline at end of file +} diff --git a/Plugin/Controller/Subscriber/NewAction.php b/Plugin/Controller/Subscriber/NewAction.php index 918b2df..043d0b9 100644 --- a/Plugin/Controller/Subscriber/NewAction.php +++ b/Plugin/Controller/Subscriber/NewAction.php @@ -21,11 +21,14 @@ namespace Mageplaza\BetterPopup\Plugin\Controller\Subscriber; +use Exception; use Magento\Customer\Api\AccountManagementInterface as CustomerAccountManagement; use Magento\Customer\Model\Session; use Magento\Customer\Model\Url as CustomerUrl; use Magento\Framework\App\Action\Context; +use Magento\Framework\Controller\Result\Json; use Magento\Framework\Controller\Result\JsonFactory; +use Magento\Framework\Exception\LocalizedException; use Magento\Newsletter\Model\SubscriberFactory; use Magento\Store\Model\StoreManagerInterface; use Mageplaza\BetterPopup\Helper\Data; @@ -37,17 +40,18 @@ class NewAction extends \Magento\Newsletter\Controller\Subscriber\NewAction { /** - * @var \Magento\Framework\Controller\Result\JsonFactory + * @var JsonFactory */ protected $resultJsonFactory; /** - * @var \Mageplaza\BetterPopup\Helper\Data + * @var Data */ protected $_helperData; /** * NewAction constructor. + * * @param Context $context * @param SubscriberFactory $subscriberFactory * @param Session $customerSession @@ -66,18 +70,25 @@ public function __construct( CustomerAccountManagement $customerAccountManagement, JsonFactory $resultJsonFactory, Data $helperData - ) - { + ) { $this->resultJsonFactory = $resultJsonFactory; - $this->_helperData = $helperData; + $this->_helperData = $helperData; - parent::__construct($context, $subscriberFactory, $customerSession, $storeManager, $customerUrl, $customerAccountManagement); + parent::__construct( + $context, + $subscriberFactory, + $customerSession, + $storeManager, + $customerUrl, + $customerAccountManagement + ); } /** * @param $subject * @param $proceed - * @return \Magento\Framework\Controller\Result\Json + * + * @return Json */ public function aroundExecute($subject, $proceed) { @@ -87,7 +98,7 @@ public function aroundExecute($subject, $proceed) $response = []; if ($this->getRequest()->isPost() && $this->getRequest()->getPost('email')) { - $email = (string)$this->getRequest()->getPost('email'); + $email = (string) $this->getRequest()->getPost('email'); try { $this->validateEmailFormat($email); @@ -96,14 +107,16 @@ public function aroundExecute($subject, $proceed) $this->_subscriberFactory->create()->subscribe($email); if (!$this->_helperData->versionCompare('2.2.0')) { - $this->_subscriberFactory->create()->loadByEmail($email)->setChangeStatusAt(date("Y-m-d h:i:s"))->save(); + $this->_subscriberFactory->create() + ->loadByEmail($email) + ->setChangeStatusAt(date('Y-m-d h:i:s'))->save(); } - } catch (\Magento\Framework\Exception\LocalizedException $e) { + } catch (LocalizedException $e) { $response = [ 'success' => true, 'msg' => __('There was a problem with the subscription: %1', $e->getMessage()), ]; - } catch (\Exception $e) { + } catch (Exception $e) { $response = [ 'status' => 'ERROR', 'msg' => __('Something went wrong with the subscription: %1', $e->getMessage()), @@ -113,4 +126,4 @@ public function aroundExecute($subject, $proceed) return $this->resultJsonFactory->create()->setData($response); } -} \ No newline at end of file +} diff --git a/USER-GUIDE.md b/USER-GUIDE.md index 9a542b9..5030c6d 100644 --- a/USER-GUIDE.md +++ b/USER-GUIDE.md @@ -4,7 +4,7 @@ - User Guide: https://docs.mageplaza.com/better-popup/ - Product page: https://www.mageplaza.com/magento-2-better-popup/ - FAQs: https://www.mageplaza.com/faqs/ -- Get Support: https://mageplaza.freshdesk.com/ or support@mageplaza.com +- Get Support: https://www.mageplaza.com/contact.html or support@mageplaza.com - Changelog: https://www.mageplaza.com/releases/better-popup/ - License agreement: https://www.mageplaza.com/LICENSE.txt diff --git a/UserGuide.pdf b/UserGuide.pdf index 2cb28ce..5c22a9a 100644 Binary files a/UserGuide.pdf and b/UserGuide.pdf differ diff --git a/composer.json b/composer.json index 0c22aae..aeb02d5 100644 --- a/composer.json +++ b/composer.json @@ -2,10 +2,10 @@ "name": "mageplaza/module-better-popup", "description": "Magento 2 Better Popup", "require": { - "mageplaza/module-core": "^1.3.13" + "mageplaza/module-core": "^1.4.4" }, "type": "magento2-module", - "version": "1.1.0", + "version": "1.1.1", "license": "proprietary", "authors": [ { diff --git a/etc/adminhtml/system.xml b/etc/adminhtml/system.xml old mode 100644 new mode 100755 index 41b13b1..4c1f0a2 --- a/etc/adminhtml/system.xml +++ b/etc/adminhtml/system.xml @@ -52,6 +52,7 @@ + validate-digits In pixel 1 @@ -59,6 +60,7 @@ + validate-digits In pixel 1 diff --git a/etc/config.xml b/etc/config.xml index 4a8477a..6063fcf 100644 --- a/etc/config.xml +++ b/etc/config.xml @@ -23,6 +23,9 @@ + + 1 + 1 diff --git a/i18n/en_US.csv b/i18n/en_US.csv index d097212..0a60196 100644 --- a/i18n/en_US.csv +++ b/i18n/en_US.csv @@ -1,10 +1,17 @@ "Default Template","Default Template" "Template 1","Template 1" "Template 2","Template 2" +"Template 3","Template 3" +"Use the following code to show the popup block in any place you want","Use the following code to show the popup block in any place you want" +"CMS Page/Static Block","CMS Page/Static Block" +"Template .phtml file","Template .phtml file" +"Layout file","Layout file" Subscribers,Subscribers +Subscribe,Subscribe "Sent successfully! Please check your email box.","Sent successfully! Please check your email box." "There is an error occurred while sending email. Please try again later.","There is an error occurred while sending email. Please try again later." "Please enter email and save config","Please enter email and save config" +"Please enter the value into one of the following boxes: Include page(s) and Include Page(s) with URL contains.","Please enter the value into one of the following boxes: Include page(s) and Include Page(s) with URL contains." "Exit Intent","Exit Intent" "After page loaded","After page loaded" "After X seconds","After X seconds" @@ -21,11 +28,18 @@ Right,Right Today,Today Week,Week Month,Month -"Show Popup","Show Popup" +"No one registers for a week","No one registers for a week" "Better Popup results for %currentTime - %store_name","Better Popup results for %currentTime - %store_name" -"Your results for %currentTime","Your results for %currentTime" +"Results for %currentTime","Results for %currentTime" +%store_name,%store_name %mp_subscriber,%mp_subscriber -%mp_unSubscriber,%mp_unSubscriber +"New Subscriber(s)","New Subscriber(s)" +"This list shows only 8 most recent subscribers this week. To see all the subscribers list, please log into your admin panel:","This list shows only 8 most recent subscribers this week. To see all the subscribers list, please log into your admin panel:" +MARKETING,MARKETING +Communications,Communications +"Newsletter Subscribers","Newsletter Subscribers" +"Happy marketing,","Happy marketing," +"The Mageplaza Team","The Mageplaza Team" Success,Success Error,Error "Are you sure to load HTML?","Are you sure to load HTML?" @@ -48,7 +62,9 @@ Height,Height "Where to Show","Where to Show" "Page(s) to show","Page(s) to show" "Include page(s)","Include page(s)" -"Example: cms_index_index (for homepage)
Separated by a new line","Example: cms_index_index (for homepage)
Separated by a new line" +"Example: cms_index_index (for homepage)
+ Separated by a new line","Example: cms_index_index (for homepage)
+ Separated by a new line" "Exclude page(s)","Exclude page(s)" "Insert manually this snippet to your page","Insert manually this snippet to your page" "When to Show","When to Show" @@ -58,8 +74,11 @@ Height,Height "Show floating button","Show floating button" "Click trigger to open","Click trigger to open" "Floating button position","Floating button position" +"Button label","Button label" "Send Email","Send Email" "Enable Send Email","Enable Send Email" "Select Yes to enable Send email function. Install Mageplaza_SMTP to avoid sending to spam box.","Select Yes to enable Send email function. Install Mageplaza_SMTP to avoid sending to spam box." "Send Email To","Send Email To" -"Please enter email address, then click Save config.
Automatically send email notifications to store owners every Saturday","Please enter email address, then click Save config.
Automatically send email notifications to store owners every Saturday" +"Please enter email address, then click Save config.
+ Automatically send email notifications to store owners every Saturday","Please enter email address, then click Save config.
+ Automatically send email notifications to store owners every Saturday" diff --git a/registration.php b/registration.php index 1e141a0..8f48e18 100644 --- a/registration.php +++ b/registration.php @@ -19,8 +19,10 @@ * @license https://www.mageplaza.com/LICENSE.txt */ -\Magento\Framework\Component\ComponentRegistrar::register( - \Magento\Framework\Component\ComponentRegistrar::MODULE, +use Magento\Framework\Component\ComponentRegistrar; + +ComponentRegistrar::register( + ComponentRegistrar::MODULE, 'Mageplaza_BetterPopup', __DIR__ ); diff --git a/view/adminhtml/templates/dashboard/newsletter.phtml b/view/adminhtml/templates/dashboard/newsletter.phtml index 782713f..090318b 100644 --- a/view/adminhtml/templates/dashboard/newsletter.phtml +++ b/view/adminhtml/templates/dashboard/newsletter.phtml @@ -19,29 +19,29 @@ * @license https://www.mageplaza.com/LICENSE.txt */ -$storeId = $this->helper('Mageplaza\BetterPopup\Helper\Data')->getStoreId(); +$storeId = $this->helper(\Mageplaza\BetterPopup\Helper\Data::class)->getStoreId(); $subscriberToday = $block->getSubscriberToday() ? $block->getSubscriberToday()->getSize() : 0; $subscriberWeek = $block->getSubscriberInWeek() ? $block->getSubscriberInWeek($storeId)->getSize() : 0; $subscriberMonth = $block->getSubscriberInMonth() ? $block->getSubscriberInMonth()->getSize() : 0; ?>
-
+
- - - + + + - - - + + +
-
\ No newline at end of file + diff --git a/view/adminhtml/templates/system/config/button.phtml b/view/adminhtml/templates/system/config/button.phtml index 7311ed8..3355564 100644 --- a/view/adminhtml/templates/system/config/button.phtml +++ b/view/adminhtml/templates/system/config/button.phtml @@ -22,8 +22,8 @@ /** @var \Mageplaza\BetterPopup\Block\Adminhtml\System\Config\Button $block */ ?>
-
\ No newline at end of file + diff --git a/view/adminhtml/templates/system/config/template.phtml b/view/adminhtml/templates/system/config/template.phtml index 8eef009..bc8783c 100644 --- a/view/adminhtml/templates/system/config/template.phtml +++ b/view/adminhtml/templates/system/config/template.phtml @@ -23,13 +23,13 @@
-
@@ -37,7 +37,7 @@ { "#mageplaza_betterpopup_templates": { "mageplaza/templates": { - "jsonDataInfo": getDataInfo() ?> + "jsonDataInfo": getDataInfo() ?> } } } diff --git a/view/frontend/templates/email/list.phtml b/view/frontend/templates/email/list.phtml index cdb6a91..def783b 100644 --- a/view/frontend/templates/email/list.phtml +++ b/view/frontend/templates/email/list.phtml @@ -20,20 +20,20 @@ */ $listEmailSubscribers = array_reverse($block->getListEmailSubscriberWeek()); -if ($listEmailSubscribers): ?> +if ($listEmailSubscribers) : ?>
    - - + +
  • -
  • +
- + diff --git a/view/frontend/templates/insertpopup.phtml b/view/frontend/templates/insertpopup.phtml index e3dea9e..2b50a50 100644 --- a/view/frontend/templates/insertpopup.phtml +++ b/view/frontend/templates/insertpopup.phtml @@ -19,33 +19,33 @@ * @license https://www.mageplaza.com/LICENSE.txt */ -if ($block->isManuallyInsert()): +if ($block->isManuallyInsert()) : $floatLocation = ($block->getLocationFloatButton() == 1) ? 'left: 70px' : 'right:70px'; ?>
-