init
This commit is contained in:
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
/**
|
||||
* Mageplaza
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Mageplaza.com license that is
|
||||
* available through the world-wide-web at this URL:
|
||||
* https://www.mageplaza.com/LICENSE.txt
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade this extension to newer
|
||||
* version in the future.
|
||||
*
|
||||
* @category Mageplaza
|
||||
* @package Mageplaza_Blog
|
||||
* @copyright Copyright (c) Mageplaza (https://www.mageplaza.com/)
|
||||
* @license https://www.mageplaza.com/LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Mageplaza\Blog\Plugin\Catalog;
|
||||
|
||||
use Magento\Catalog\Model\ResourceModel\Product\Collection;
|
||||
use Magento\Framework\App\RequestInterface;
|
||||
use Mageplaza\Blog\Helper\Data;
|
||||
|
||||
/**
|
||||
* Class AttributeSort
|
||||
* @package Mageplaza\Blog\Plugin\Catalog
|
||||
*/
|
||||
class AttributeSort
|
||||
{
|
||||
/**
|
||||
* @var Data
|
||||
*/
|
||||
protected $helper;
|
||||
|
||||
/**
|
||||
* @var RequestInterface
|
||||
*/
|
||||
protected $request;
|
||||
|
||||
/**
|
||||
* AttributeSort constructor.
|
||||
*
|
||||
* @param RequestInterface $request
|
||||
* @param Data $helper
|
||||
*/
|
||||
public function __construct(
|
||||
RequestInterface $request,
|
||||
Data $helper
|
||||
) {
|
||||
$this->helper = $helper;
|
||||
$this->request = $request;
|
||||
}
|
||||
|
||||
public function aroundAddAttributeToSort(
|
||||
Collection $productCollection,
|
||||
callable $proceed,
|
||||
$attribute,
|
||||
$dir
|
||||
) {
|
||||
if ($attribute === 'position' &&
|
||||
in_array(
|
||||
$this->request->getFullActionName(),
|
||||
['mageplaza_blog_post_products', 'mageplaza_blog_post_productsGrid'],
|
||||
true
|
||||
)
|
||||
) {
|
||||
$productCollection->getSelect()->order('position ' . $dir);
|
||||
|
||||
return $productCollection;
|
||||
}
|
||||
|
||||
return $proceed($attribute, $dir);
|
||||
}
|
||||
}
|
||||
+100
@@ -0,0 +1,100 @@
|
||||
<?php
|
||||
/**
|
||||
* Mageplaza
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Mageplaza.com license that is
|
||||
* available through the world-wide-web at this URL:
|
||||
* https://www.mageplaza.com/LICENSE.txt
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade this extension to newer
|
||||
* version in the future.
|
||||
*
|
||||
* @category Mageplaza
|
||||
* @package Mageplaza_Blog
|
||||
* @copyright Copyright (c) Mageplaza (https://www.mageplaza.com/)
|
||||
* @license https://www.mageplaza.com/LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Mageplaza\Blog\Plugin\Customer;
|
||||
|
||||
use Magento\Framework\Module\Manager as ModuleManager;
|
||||
use Magento\Framework\View\Element\Html\Link;
|
||||
use Magento\Framework\View\Element\Html\Links;
|
||||
use Mageplaza\Blog\Helper\Data;
|
||||
|
||||
/**
|
||||
* Class LinkMenu
|
||||
* @package Mageplaza\Blog\Plugin\Customer
|
||||
*/
|
||||
class LinkMenu
|
||||
{
|
||||
/**
|
||||
* @var ModuleManager
|
||||
*/
|
||||
protected $_moduleManager;
|
||||
|
||||
/**
|
||||
* @var Data
|
||||
*/
|
||||
protected $_helper;
|
||||
|
||||
/**
|
||||
* Topmenu constructor.
|
||||
*
|
||||
* @param Data $helper
|
||||
* @param ModuleManager $moduleManager
|
||||
*/
|
||||
public function __construct(
|
||||
ModuleManager $moduleManager,
|
||||
Data $helper
|
||||
) {
|
||||
$this->_moduleManager = $moduleManager;
|
||||
$this->_helper = $helper;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Links $subject
|
||||
* @param Link[] $links
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function afterGetLinks(
|
||||
Links $subject,
|
||||
$links
|
||||
) {
|
||||
if ($this->_moduleManager->isEnabled('Mageplaza_BlogPro') && $this->_helper->getPostViewPageConfig('enable_to_save')) {
|
||||
return $links;
|
||||
} else {
|
||||
$links = $this->unsetLinks($links);
|
||||
}
|
||||
|
||||
return $links;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $links
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
protected function unsetLinks($links)
|
||||
{
|
||||
if ($links && !$this->_helper->getConfigGeneral('customer_approve')) {
|
||||
foreach ($links as $key => $link) {
|
||||
if ($link->getPath() === 'mpblog/author/signup') {
|
||||
$this->_helper->setCustomerContextId();
|
||||
$author = $this->_helper->getCurrentAuthor();
|
||||
if ($author === null || !$author->getId()) {
|
||||
unset($links[$key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $links;
|
||||
}
|
||||
|
||||
}
|
||||
Executable
+106
@@ -0,0 +1,106 @@
|
||||
<?php
|
||||
/**
|
||||
* Mageplaza
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Mageplaza.com license that is
|
||||
* available through the world-wide-web at this URL:
|
||||
* https://www.mageplaza.com/LICENSE.txt
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade this extension to newer
|
||||
* version in the future.
|
||||
*
|
||||
* @category Mageplaza
|
||||
* @package Mageplaza_Blog
|
||||
* @copyright Copyright (c) Mageplaza (https://www.mageplaza.com/)
|
||||
* @license https://www.mageplaza.com/LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Mageplaza\Blog\Plugin;
|
||||
|
||||
use Magento\Framework\Exception\LocalizedException;
|
||||
use Mageplaza\Blog\Block\Category\Menu;
|
||||
use Mageplaza\Blog\Helper\Data;
|
||||
use Magento\Framework\View\Element\Template;
|
||||
/**
|
||||
* Class Topmenu
|
||||
* @package Mageplaza\Blog\Plugin
|
||||
*/
|
||||
class HyvaMenu
|
||||
{
|
||||
/**
|
||||
* @var Data
|
||||
*/
|
||||
protected $helper;
|
||||
/**
|
||||
* @var \Magento\Framework\View\LayoutInterface
|
||||
*/
|
||||
protected $layout;
|
||||
|
||||
/**
|
||||
* Topmenu constructor.
|
||||
*
|
||||
* @param Data $helper
|
||||
*/
|
||||
public function __construct(
|
||||
Data $helper,
|
||||
\Magento\Framework\View\LayoutInterface $layout
|
||||
) {
|
||||
$this->helper = $helper;
|
||||
$this->layout = $layout;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param /Hyva\Theme\ViewModel\Navigation $subject
|
||||
* @param $data
|
||||
*
|
||||
* @return string
|
||||
* @throws LocalizedException
|
||||
*/
|
||||
public function afterGetNavigation(
|
||||
\Hyva\Theme\ViewModel\Navigation $subject,
|
||||
array $dataSubject = []
|
||||
) {
|
||||
if ($this->helper->isEnabled() && $this->helper->getBlogConfig('display/toplinks')) {
|
||||
$blockMenu = $this->layout->createBlock(Menu::class);
|
||||
$categories = $blockMenu->getCollections();
|
||||
$childData = [];
|
||||
foreach ($categories as $key => $category) {
|
||||
$data = [
|
||||
"name" => $category->getName(),
|
||||
"id" => "mg-blog" . $category->getId(),
|
||||
"url" => $blockMenu->getBlogUrlByUrlKey($category->getUrlKey()),
|
||||
"image" => false,
|
||||
"has_active" => false,
|
||||
"is_active" => false,
|
||||
"is_category" => true,
|
||||
"is_parent_active" => true,
|
||||
"position" => null,
|
||||
"path" => $category->getPath(),
|
||||
"childData" => $blockMenu->getChildDataCate($category)
|
||||
];
|
||||
array_push($childData, $data);
|
||||
};
|
||||
|
||||
$dataSubject['mg-blog']= [
|
||||
"name" => $blockMenu->getBlogHomePageTitle(),
|
||||
"id" => "mg-blog",
|
||||
"url" => $blockMenu->getBlogHomeUrl(),
|
||||
"image" => false,
|
||||
"has_active" => false,
|
||||
"is_active" => false,
|
||||
"is_category" => true,
|
||||
"is_parent_active" => true,
|
||||
"position" => null,
|
||||
"path" => $blockMenu->getPath(),
|
||||
"childData" => $childData
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
return $dataSubject;
|
||||
}
|
||||
}
|
||||
+67
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
/**
|
||||
* Mageplaza
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Mageplaza.com license that is
|
||||
* available through the world-wide-web at this URL:
|
||||
* https://www.mageplaza.com/LICENSE.txt
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade this extension to newer
|
||||
* version in the future.
|
||||
*
|
||||
* @category Mageplaza
|
||||
* @package Mageplaza_Blog
|
||||
* @copyright Copyright (c) Mageplaza (https://www.mageplaza.com/)
|
||||
* @license https://www.mageplaza.com/LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Mageplaza\Blog\Plugin;
|
||||
|
||||
use Infortis\UltraMegamenu\Block\Navigation;
|
||||
use Mageplaza\Blog\Block\Category\Menu;
|
||||
use Mageplaza\Blog\Helper\Data;
|
||||
|
||||
/**
|
||||
* Class InfortisTopmenu
|
||||
* @package Mageplaza\Blog\Plugin
|
||||
*/
|
||||
class InfortisTopmenu
|
||||
{
|
||||
/**
|
||||
* @var Data
|
||||
*/
|
||||
protected $helper;
|
||||
|
||||
/**
|
||||
* PortoTopmenu constructor.
|
||||
*
|
||||
* @param Data $helper
|
||||
*/
|
||||
public function __construct(
|
||||
Data $helper
|
||||
) {
|
||||
$this->helper = $helper;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Navigation $topmenu
|
||||
* @param $html
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function afterRenderCategoriesMenuHtml(Navigation $topmenu, $html)
|
||||
{
|
||||
if ($this->helper->isEnabled() && $this->helper->getBlogConfig('display/toplinks')) {
|
||||
$blogHtml = $topmenu->getLayout()->createBlock(Menu::class)
|
||||
->setTemplate('Mageplaza_Blog::category/topmenu.phtml')->toHtml();
|
||||
|
||||
return $html . $blogHtml;
|
||||
}
|
||||
|
||||
return $html;
|
||||
}
|
||||
}
|
||||
+66
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
/**
|
||||
* Mageplaza
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Mageplaza.com license that is
|
||||
* available through the world-wide-web at this URL:
|
||||
* https://www.mageplaza.com/LICENSE.txt
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade this extension to newer
|
||||
* version in the future.
|
||||
*
|
||||
* @category Mageplaza
|
||||
* @package Mageplaza_Blog
|
||||
* @copyright Copyright (c) Mageplaza (https://www.mageplaza.com/)
|
||||
* @license https://www.mageplaza.com/LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Mageplaza\Blog\Plugin;
|
||||
|
||||
use Mageplaza\Blog\Block\Category\Menu;
|
||||
use Mageplaza\Blog\Helper\Data;
|
||||
|
||||
/**
|
||||
* Class PortoTopmenu
|
||||
* @package Mageplaza\Blog\Plugin
|
||||
*/
|
||||
class PortoTopmenu
|
||||
{
|
||||
/**
|
||||
* @var Data
|
||||
*/
|
||||
protected $helper;
|
||||
|
||||
/**
|
||||
* PortoTopmenu constructor.
|
||||
*
|
||||
* @param Data $helper
|
||||
*/
|
||||
public function __construct(
|
||||
Data $helper
|
||||
) {
|
||||
$this->helper = $helper;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Smartwave\Megamenu\Block\Topmenu $topmenu
|
||||
* @param $html
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function afterGetMegamenuHtml(\Smartwave\Megamenu\Block\Topmenu $topmenu, $html)
|
||||
{
|
||||
if ($this->helper->isEnabled() && $this->helper->getBlogConfig('display/toplinks')) {
|
||||
$blogHtml = $topmenu->getLayout()->createBlock(Menu::class)
|
||||
->setTemplate('Mageplaza_Blog::category/topPortoMenu.phtml')->toHtml();
|
||||
|
||||
return $html . $blogHtml;
|
||||
}
|
||||
|
||||
return $html;
|
||||
}
|
||||
}
|
||||
+94
@@ -0,0 +1,94 @@
|
||||
<?php
|
||||
/**
|
||||
* Mageplaza
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Mageplaza.com license that is
|
||||
* available through the world-wide-web at this URL:
|
||||
* https://www.mageplaza.com/LICENSE.txt
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade this extension to newer
|
||||
* version in the future.
|
||||
*
|
||||
* @category Mageplaza
|
||||
* @package Mageplaza_Blog
|
||||
* @copyright Copyright (c) Mageplaza (https://www.mageplaza.com/)
|
||||
* @license https://www.mageplaza.com/LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Mageplaza\Blog\Plugin\System\Config;
|
||||
|
||||
use Magento\Framework\Data\Form\Element\AbstractElement;
|
||||
use Magento\Framework\Module\Manager;
|
||||
use Mageplaza\Core\Block\Adminhtml\System\Config\Docs;
|
||||
|
||||
/**
|
||||
* Class Banner
|
||||
* @package Mageplaza\Blog\Plugin\System\Config
|
||||
*/
|
||||
class Banner
|
||||
{
|
||||
/**
|
||||
* @var Manager
|
||||
*/
|
||||
protected $_moduleManager;
|
||||
|
||||
/**
|
||||
* Banner constructor.
|
||||
*
|
||||
* @param Manager $moduleManager
|
||||
*/
|
||||
public function __construct(
|
||||
Manager $moduleManager
|
||||
) {
|
||||
$this->_moduleManager = $moduleManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Docs $subject
|
||||
* @param $result
|
||||
* @param AbstractElement $element
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function afterRender(Docs $subject, $result, AbstractElement $element)
|
||||
{
|
||||
if ($this->isHideBanner($element)) {
|
||||
return $result;
|
||||
}
|
||||
$bannerImg = $subject->getViewFileUrl('Mageplaza_Blog::media/banner/banner.png');
|
||||
$html = <<<HTML
|
||||
<script>
|
||||
require([ 'jquery'], function ($) {
|
||||
var session = $(".accordion" );
|
||||
$("<a target='_blank' href='https://www.mageplaza.com/magento-2-better-blog/?utm_source=dashboard&utm_medium=admin&utm_campaign=blogpro'>" +
|
||||
"<img src='{$bannerImg}'></a>").insertBefore(session);
|
||||
})
|
||||
</script>
|
||||
HTML;
|
||||
|
||||
$result = $html . $result;
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $element
|
||||
* @return bool
|
||||
*/
|
||||
protected function isHideBanner($element)
|
||||
{
|
||||
if ($element->getOriginalData()['module_name'] !== 'Mageplaza_Blog') {
|
||||
return true;
|
||||
}
|
||||
|
||||
if ($this->_moduleManager->isOutputEnabled('Mageplaza_BlogPro')) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Executable
+70
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
/**
|
||||
* Mageplaza
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Mageplaza.com license that is
|
||||
* available through the world-wide-web at this URL:
|
||||
* https://www.mageplaza.com/LICENSE.txt
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade this extension to newer
|
||||
* version in the future.
|
||||
*
|
||||
* @category Mageplaza
|
||||
* @package Mageplaza_Blog
|
||||
* @copyright Copyright (c) Mageplaza (https://www.mageplaza.com/)
|
||||
* @license https://www.mageplaza.com/LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Mageplaza\Blog\Plugin;
|
||||
|
||||
use Magento\Framework\Exception\LocalizedException;
|
||||
use Mageplaza\Blog\Block\Category\Menu;
|
||||
use Mageplaza\Blog\Helper\Data;
|
||||
|
||||
/**
|
||||
* Class Topmenu
|
||||
* @package Mageplaza\Blog\Plugin
|
||||
*/
|
||||
class Topmenu
|
||||
{
|
||||
/**
|
||||
* @var Data
|
||||
*/
|
||||
protected $helper;
|
||||
|
||||
/**
|
||||
* Topmenu constructor.
|
||||
*
|
||||
* @param Data $helper
|
||||
*/
|
||||
public function __construct(
|
||||
Data $helper
|
||||
) {
|
||||
$this->helper = $helper;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Magento\Theme\Block\Html\Topmenu $subject
|
||||
* @param $html
|
||||
*
|
||||
* @return string
|
||||
* @throws LocalizedException
|
||||
*/
|
||||
public function afterGetHtml(
|
||||
\Magento\Theme\Block\Html\Topmenu $subject,
|
||||
$html
|
||||
) {
|
||||
if ($this->helper->isEnabled() && $this->helper->getBlogConfig('display/toplinks')) {
|
||||
$blogHtml = $subject->getLayout()->createBlock(Menu::class)
|
||||
->setTemplate('Mageplaza_Blog::category/topmenu.phtml')->toHtml();
|
||||
|
||||
return $html . $blogHtml;
|
||||
}
|
||||
|
||||
return $html;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user