-
Notifications
You must be signed in to change notification settings - Fork 0
/
wp-multi-block.php
75 lines (68 loc) · 1.8 KB
/
wp-multi-block.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<?php
/**
* Plugin Name: Wp Multi Block
* Description: Example block scaffolded with Create Block tool.
* Requires at least: 6.6
* Requires PHP: 7.0
* Version: 0.1.0
* Author: The WordPress Contributors
* License: GPL-2.0-or-later
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
* Text Domain: wp-multi-block
*
* @package CreateBlock
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
/**
* Registers the blocks using block.json files
*/
function multiblock_register_blocks() {
$custom_blocks = array (
'block-one',
'block-two',
'block-three',
'block-four',
);
foreach ( $custom_blocks as $block ) {
register_block_type( __DIR__ . '/build/blocks/' . $block );
}
}
add_action( 'init', 'multiblock_register_blocks' );
/**
* Enqueues the block assets for the editor
*/
function multiblock_enqueue_block_assets() {
wp_enqueue_script(
'multi-block-editor-js',
plugin_dir_url( __FILE__ ) . 'build/multi-block-editor.js',
array('wp-blocks', 'wp-components', 'wp-data', 'wp-dom-ready', 'wp-edit-post', 'wp-element', 'wp-i18n', 'wp-plugins'),
null,
false
);
wp_enqueue_style(
'multi-block-editor-css',
plugin_dir_url( __FILE__ ) . 'build/multi-block-editor.css',
array(),
null
);
}
add_action( 'enqueue_block_editor_assets', 'multiblock_enqueue_block_assets' );
/**
* Enqueues the block assets for the frontend
*/
function multiblock_enqueue_frontend_assets() {
wp_enqueue_style(
'multi-block-frontend-css',
plugin_dir_url( __FILE__ ) . 'build/style-multi-block-editor.css',
);
wp_enqueue_script(
'multi-block-frontend-js',
plugin_dir_url( __FILE__ ) . 'build/multi-block-frontend.js',
array(),
null,
true
);
}
add_action( 'wp_enqueue_scripts', 'multiblock_enqueue_frontend_assets' );