Create basic block

[MAILPOET-1798]
This commit is contained in:
Pavel Dohnal
2020-01-30 14:05:51 +01:00
committed by Jack Kitterhing
parent f11102ab34
commit 261624c2bb
8 changed files with 87 additions and 1 deletions

View File

@ -0,0 +1,44 @@
<?php
namespace MailPoet\Config;
use MailPoet\WP\Functions as WPFunctions;
class PostEditorBlock {
/** @var Renderer */
private $renderer;
/** @var WPFunctions */
private $wp;
public function __construct(Renderer $renderer, WPFunctions $wp) {
$this->renderer = $renderer;
$this->wp = $wp;
}
public function init() {
// this has to be here until we drop support for WordPress < 5.0
if (!function_exists('register_block_type')) return;
$this->wp->wpEnqueueScript(
'mailpoet-block-form-block-js',
Env::$assetsUrl . '/dist/js/' . $this->renderer->getJsAsset('post_editor_block.js'),
['wp-blocks'],
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
);
register_block_type( 'mailpoet/form-block', [
'style' => 'mailpoetblock-form-block-css',
'editor_script' => 'mailpoet/form-block',
]);
}
}