Use subscription in the block name
[MAILPOET-1798]
This commit is contained in:
committed by
Jack Kitterhing
parent
4da5b2e5c4
commit
f4b9836332
@@ -1 +1 @@
|
|||||||
import './form_block.jsx';
|
import './subscription_form/form_block.jsx';
|
||||||
|
@@ -4,7 +4,7 @@ import Edit from './edit.jsx';
|
|||||||
const wp = window.wp;
|
const wp = window.wp;
|
||||||
const { registerBlockType } = wp.blocks;
|
const { registerBlockType } = wp.blocks;
|
||||||
|
|
||||||
registerBlockType('mailpoet/form-block', {
|
registerBlockType('mailpoet/subscription-form-block', {
|
||||||
title: window.locale.subscriptionForm,
|
title: window.locale.subscriptionForm,
|
||||||
icon: Icon,
|
icon: Icon,
|
||||||
category: 'widgets',
|
category: 'widgets',
|
@@ -1,15 +1,13 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace MailPoet\PostEditorBlocks;
|
namespace MailPoet\Config;
|
||||||
|
|
||||||
use MailPoet\Config\Env;
|
|
||||||
use MailPoet\Config\Renderer;
|
|
||||||
use MailPoet\Entities\FormEntity;
|
use MailPoet\Entities\FormEntity;
|
||||||
use MailPoet\Form\FormsRepository;
|
use MailPoet\Form\FormsRepository;
|
||||||
use MailPoet\Form\Widget;
|
use MailPoet\Form\Widget;
|
||||||
use MailPoet\WP\Functions as WPFunctions;
|
use MailPoet\WP\Functions as WPFunctions;
|
||||||
|
|
||||||
class SubscriptionFormBlock {
|
class PostEditorBlock {
|
||||||
/** @var Renderer */
|
/** @var Renderer */
|
||||||
private $renderer;
|
private $renderer;
|
||||||
|
|
||||||
@@ -30,7 +28,16 @@ class SubscriptionFormBlock {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function init() {
|
public function init() {
|
||||||
$this->wp->registerBlockType('mailpoet/subscription-form-block-render', [
|
// this has to be here until we drop support for WordPress < 5.0
|
||||||
|
if (!function_exists('register_block_type')) return;
|
||||||
|
|
||||||
|
if (is_admin()) {
|
||||||
|
$this->initAdmin();
|
||||||
|
} else {
|
||||||
|
$this->initFrontend();
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->wp->registerBlockType('mailpoet/form-block-render', [
|
||||||
'attributes' => [
|
'attributes' => [
|
||||||
'form' => [
|
'form' => [
|
||||||
'type' => 'number',
|
'type' => 'number',
|
||||||
@@ -41,10 +48,25 @@ class SubscriptionFormBlock {
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function initAdmin() {
|
private function initAdmin() {
|
||||||
$this->wp->registerBlockType('mailpoet/subscription-form-block', [
|
$this->wp->wpEnqueueScript(
|
||||||
|
'mailpoet-block-form-block-js',
|
||||||
|
Env::$assetsUrl . '/dist/js/' . $this->renderer->getJsAsset('post_editor_block.js'),
|
||||||
|
['wp-blocks', 'wp-components', 'wp-server-side-render', 'wp-block-editor'],
|
||||||
|
Env::$version,
|
||||||
|
true
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->wp->wpEnqueueStyle(
|
||||||
|
'mailpoetblock-form-block-css',
|
||||||
|
Env::$assetsUrl . '/dist/css/' . $this->renderer->getCssAsset('post-editor-block.css'),
|
||||||
|
['wp-edit-blocks'],
|
||||||
|
Env::$version
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->wp->registerBlockType('mailpoet/form-block', [
|
||||||
'style' => 'mailpoetblock-form-block-css',
|
'style' => 'mailpoetblock-form-block-css',
|
||||||
'editor_script' => 'mailpoet/subscription-form-block',
|
'editor_script' => 'mailpoet/form-block',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$this->wp->addAction('admin_head', function() {
|
$this->wp->addAction('admin_head', function() {
|
||||||
@@ -64,8 +86,8 @@ class SubscriptionFormBlock {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public function initFrontend() {
|
private function initFrontend() {
|
||||||
$this->wp->registerBlockType('mailpoet/subscription-form-block', [
|
$this->wp->registerBlockType('mailpoet/form-block', [
|
||||||
'render_callback' => [$this, 'renderForm'],
|
'render_callback' => [$this, 'renderForm'],
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
@@ -80,4 +102,5 @@ class SubscriptionFormBlock {
|
|||||||
'form_type' => 'html',
|
'form_type' => 'html',
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user