Show Products widget only when WC is active
[MAILPOET-1843]
This commit is contained in:
committed by
Rostislav Wolný
parent
42f43e96e1
commit
e2080eea2d
@ -548,6 +548,9 @@ Module.ProductsWidgetView = base.WidgetView.extend({
|
|||||||
});
|
});
|
||||||
|
|
||||||
App.on('before:start', function beforeStartApp(BeforeStartApp) {
|
App.on('before:start', function beforeStartApp(BeforeStartApp) {
|
||||||
|
if (!window.mailpoet_woocommerce_active) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
BeforeStartApp.registerBlockType('products', {
|
BeforeStartApp.registerBlockType('products', {
|
||||||
blockModel: Module.ProductsBlockModel,
|
blockModel: Module.ProductsBlockModel,
|
||||||
blockView: Module.ProductsBlockView,
|
blockView: Module.ProductsBlockView,
|
||||||
|
@ -6,6 +6,7 @@ use Carbon\Carbon;
|
|||||||
use MailPoet\Config\ServicesChecker;
|
use MailPoet\Config\ServicesChecker;
|
||||||
use MailPoet\Settings\SettingsController;
|
use MailPoet\Settings\SettingsController;
|
||||||
use MailPoet\Util\FreeDomains;
|
use MailPoet\Util\FreeDomains;
|
||||||
|
use MailPoet\WooCommerce\Helper as WooCommerceHelper;
|
||||||
use MailPoet\WP\Functions as WPFunctions;
|
use MailPoet\WP\Functions as WPFunctions;
|
||||||
use MailPoetVendor\Twig\Extension\AbstractExtension;
|
use MailPoetVendor\Twig\Extension\AbstractExtension;
|
||||||
use MailPoetVendor\Twig\TwigFunction;
|
use MailPoetVendor\Twig\TwigFunction;
|
||||||
@ -17,8 +18,12 @@ class Functions extends AbstractExtension {
|
|||||||
/** @var SettingsController */
|
/** @var SettingsController */
|
||||||
private $settings;
|
private $settings;
|
||||||
|
|
||||||
|
/** @var WooCommerceHelper */
|
||||||
|
private $woocommerce_helper;
|
||||||
|
|
||||||
public function __construct() {
|
public function __construct() {
|
||||||
$this->settings = new SettingsController();
|
$this->settings = new SettingsController();
|
||||||
|
$this->woocommerce_helper = new WooCommerceHelper();
|
||||||
}
|
}
|
||||||
|
|
||||||
function getFunctions() {
|
function getFunctions() {
|
||||||
@ -118,6 +123,11 @@ class Functions extends AbstractExtension {
|
|||||||
array($this, 'getFreeDomains'),
|
array($this, 'getFreeDomains'),
|
||||||
array('is_safe' => array('all'))
|
array('is_safe' => array('all'))
|
||||||
),
|
),
|
||||||
|
new TwigFunction(
|
||||||
|
'is_woocommerce_active',
|
||||||
|
array($this, 'isWoocommerceActive'),
|
||||||
|
array('is_safe' => array('all'))
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -211,4 +221,8 @@ class Functions extends AbstractExtension {
|
|||||||
function getFreeDomains() {
|
function getFreeDomains() {
|
||||||
return FreeDomains::FREE_DOMAINS;
|
return FreeDomains::FREE_DOMAINS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isWoocommerceActive() {
|
||||||
|
return $this->woocommerce_helper->isWooCommerceActive();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,7 @@ class EditorProductsCest {
|
|||||||
$I->clickItemRowActionByItemName($this->newsletterTitle, 'Edit');
|
$I->clickItemRowActionByItemName($this->newsletterTitle, 'Edit');
|
||||||
|
|
||||||
$I->waitForText('Spacer');
|
$I->waitForText('Spacer');
|
||||||
$I->waitForElementVisible('#automation_editor_block_products');
|
$I->waitForElementNotVisible('#automation_editor_block_products');
|
||||||
}
|
}
|
||||||
|
|
||||||
private function initializeWooCommerce(\AcceptanceTester $I) {
|
private function initializeWooCommerce(\AcceptanceTester $I) {
|
||||||
|
@ -54,6 +54,7 @@ jQuery('.toplevel_page_mailpoet-newsletters.menu-top-last')
|
|||||||
var mailpoet_analytics_public_id = <%= json_encode(get_analytics_public_id()) %>;
|
var mailpoet_analytics_public_id = <%= json_encode(get_analytics_public_id()) %>;
|
||||||
var mailpoet_analytics_new_public_id = <%= is_analytics_public_id_new() | json_encode %>;
|
var mailpoet_analytics_new_public_id = <%= is_analytics_public_id_new() | json_encode %>;
|
||||||
var mailpoet_free_domains = <%= json_encode(mailpoet_free_domains()) %>;
|
var mailpoet_free_domains = <%= json_encode(mailpoet_free_domains()) %>;
|
||||||
|
var mailpoet_woocommerce_active = <%= json_encode(is_woocommerce_active()) %>;
|
||||||
// RFC 5322 standard; http://emailregex.com/ combined with https://google.github.io/closure-library/api/goog.format.EmailAddress.html#isValid
|
// RFC 5322 standard; http://emailregex.com/ combined with https://google.github.io/closure-library/api/goog.format.EmailAddress.html#isValid
|
||||||
var mailpoet_email_regex = /(?=^[+a-zA-Z0-9_.!#$%&'*\/=?^`{|}~-]+@([a-zA-Z0-9-]+\.)+[a-zA-Z0-9]{2,63}$)(?=^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,})))/;
|
var mailpoet_email_regex = /(?=^[+a-zA-Z0-9_.!#$%&'*\/=?^`{|}~-]+@([a-zA-Z0-9-]+\.)+[a-zA-Z0-9]{2,63}$)(?=^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,})))/;
|
||||||
</script>
|
</script>
|
||||||
|
Reference in New Issue
Block a user