-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit.php
54 lines (49 loc) · 1.14 KB
/
init.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
<?php
/**
* Initializes the plugin files.
*
* @package TimJensen\SimpleContainerBlock
* @author Tim Jensen <[email protected]>
* @license GNU General Public License 2.0+
* @since 1.0.0
*/
namespace TimJensen\SimpleContainerBlock;
add_action( 'init', __NAMESPACE__ . '\\register_block' );
/**
* Registers the block.
*/
function register_block() {
// Only run if Gutenberg is available.
if ( ! function_exists( 'register_block_type' ) ) {
return;
}
$block_js = 'block/build/script.js';
$block_css = 'block/build/style.css';
wp_register_script(
'simple-container-block-js',
plugins_url( $block_js, SIMPLE_CONTAINER_BLOCK_PLUGIN_FILE ),
[
'wp-i18n',
'wp-blocks',
'wp-element',
'wp-components',
'wp-editor',
],
filemtime( dirname( SIMPLE_CONTAINER_BLOCK_PLUGIN_FILE ) . '/' . $block_js )
);
register_block_type(
'timothyjensen/simple-container-block', [
'editor_script' => 'simple-container-block-js',
'attributes' => [
'className' => [
'type' => 'string',
'default' => '',
],
'anchor' => [
'type' => 'string',
'default' => '',
],
],
]
);
}