Skip to content

Commit

Permalink
Merge pull request #366 from mageplaza/2.4-develop
Browse files Browse the repository at this point in the history
2.4 develop
  • Loading branch information
chuccv authored Mar 18, 2024
2 parents 69d3225 + b13b197 commit c32519a
Show file tree
Hide file tree
Showing 4 changed files with 99 additions and 1 deletion.
94 changes: 94 additions & 0 deletions Plugin/System/Config/Banner.php
Original file line number Diff line number Diff line change
@@ -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;
}
}
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"facebook/graph-sdk": "^5.7.0"
},
"type": "magento2-module",
"version": "4.2.0",
"version": "4.2.1",
"license": "proprietary",
"keywords": [
"magento 2",
Expand Down
4 changes: 4 additions & 0 deletions etc/adminhtml/di.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,8 @@
<type name="Magento\Catalog\Model\ResourceModel\Product\Collection">
<plugin name="blog-post-product-sort" type="Mageplaza\Blog\Plugin\Catalog\AttributeSort"/>
</type>
<!-- update banner in config infomation tab -->
<type name="Mageplaza\Core\Block\Adminhtml\System\Config\Docs">
<plugin name="blog-config-banner" type="Mageplaza\Blog\Plugin\System\Config\Banner"/>
</type>
</config>
Binary file added view/base/web/media/banner/banner.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit c32519a

Please sign in to comment.