Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

10878 move all blog options to the base blog #575

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions Block/Adminhtml/System/Config/Form/InfoBlogExtra.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php
/**
* Copyright © Magefan ([email protected]). All rights reserved.
* Please visit Magefan.com for license details (https://magefan.com/end-user-license-agreement).
*/

declare(strict_types=1);

namespace Magefan\Blog\Block\Adminhtml\System\Config\Form;

class InfoBlogExtra extends InfoPlan
{

/**
* @return string
*/
protected function getMinPlan(): string
{
return 'Extra';
}

/**
* @return string
*/
protected function getSectionId(): string
{
$sections = json_encode([
'mfblog_post_view_category_posts',
'mfblog_post_view_comments_enabled',
'mfblog_post_view_comments_admin_enable_comment_notification',
'mfblog_post_view_comments_email_template',
'mfblog_post_view_comments_sender_form',
'mfblog_post_view_comments_admin_send_from',
'mfblog_post_view_comments_admin_send_to',
'mfblog_post_view_comments_admin_email_template',
'mfblog_blog_search',
'mfblog_sidebar_contents'
]);
return $sections;
}
protected function getText(): string
{
return 'This option is available in <strong>Extra</strong> plan only.';

}
}
44 changes: 44 additions & 0 deletions Block/Adminhtml/System/Config/Form/InfoBlogPlus.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php
/**
* Copyright © Magefan ([email protected]). All rights reserved.
* Please visit Magefan.com for license details (https://magefan.com/end-user-license-agreement).
*/

declare(strict_types=1);

namespace Magefan\Blog\Block\Adminhtml\System\Config\Form;

class InfoBlogPlus extends InfoPlan
{

/**
* @return string
*/
protected function getMinPlan(): string
{
return 'Plus';
}

/**
* @return string
*/
protected function getSectionId(): string
{
$sections = json_encode([
'mfblog_post_view_related_posts_autorelated_enabled',
'mfblog_post_view_related_products_autorelated_enabled',
'mfblog_post_view_comments_format_date',
'mfblog_sidebar_archive_format_date',
'mfblog_post_view_related_products_autorelated_black_words',
'mfblog_post_view_related_posts_autorelated_black_words',
'mfblog_design',
'mfblog_advanced_permalink',
'mfblog_sitemap'
]);
return $sections;
}
protected function getText(): string
{
return 'Google Ads options are available in <strong>Plus or Extra</strong> plans only.';
}
}
93 changes: 93 additions & 0 deletions Block/Adminhtml/System/Config/Form/InfoPlan.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
<?php
/**
* Copyright © Magefan ([email protected]). All rights reserved.
* Please visit Magefan.com for license details (https://magefan.com/end-user-license-agreement).
*/

declare(strict_types=1);

namespace Magefan\Blog\Block\Adminhtml\System\Config\Form;

abstract class InfoPlan extends \Magefan\Community\Block\Adminhtml\System\Config\Form\Info
{
/**
* @return string
*/
abstract protected function getMinPlan(): string;

/**
* @return string
*/
abstract protected function getSectionId(): string;

/**
* @return string
*/
abstract protected function getText(): string;


/**
* Return info block html
* @param \Magento\Framework\Data\Form\Element\AbstractElement $element
* @return string
*/
public function render(\Magento\Framework\Data\Form\Element\AbstractElement $element)
{
if ($this->getModuleVersion->execute($this->getModuleName() . $this->getMinPlan())) {
return '';
}

$html = '';

$html .= '<script>
require(["jquery", "Magento_Ui/js/modal/alert", "domReady!"], function($, alert){
setInterval(function(){
var json = ' . $this->getSectionId() . ';
json.forEach(function(element) {
var $section = $("#" + element + "-state").parent(".section-config");
var $formatDateField = $("#" + element);

function disableField($field) {
$field.attr("readonly", "readonly");
$field.removeAttr("disabled");
if ($field.data("mbdisabled")) return;
$field.data("mbdisabled", 1);
$field.click(function(){
alert({
title: "You can not change this option.",
content: "' . ($this->getMinPlan() == "Extra" ? 'This option is available in <strong>Extra</strong> plan only.' : 'This option is available in <strong>Plus or Extra</strong> plans only.') . '",
buttons: [{
text: "Upgrade Plan Now",
class: "action primary accept",
click: function () {
window.open("https://magefan.com/magento2-blog-extension/pricing?utm_source=gtm_config&utm_medium=link&utm_campaign=regular");
}
}]
});
});
}

if ($section.length) {
$section.find(".use-default").css("visibility", "hidden");
$section.find("input,select").each(function(){
disableField($(this));
});
if ($section.data("mbdisabled")) return;
$section.data("mbdisabled", 1);
var customHtml = \'<div style="padding:10px;background-color:#f8f8f8;border:1px solid #ddd;margin-bottom:7px;">' . $this->getText() . ' <a style="color: #ef672f; text-decoration: underline;" href="https://magefan.com/magento2-blog-extension/pricing?utm_source=gtm_config&utm_medium=link&utm_campaign=regular" target="_blank">Read more</a>.</div>\';
console.log($section.find([id$="state"]).parent(".section-config"));
$($section.find("fieldset")).prepend(customHtml);

} else {
$("#row_" + element).find(".use-default").css("visibility", "hidden");
disableField($formatDateField);
}
});

}, 1000);
});
</script>';

return $html;
}
}
Loading