-
Notifications
You must be signed in to change notification settings - Fork 1
/
test-block.php
43 lines (36 loc) · 958 Bytes
/
test-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
<?php
/**
* Plugin Name: Test Block
* Plugin URI: https://github.com/mkaz/test-block
* Description: A block to test with
* Version: 0.1.0
* Author: Marcus Kazmierczak
* Author URI: https://mkaz.blog/
*
* @package checkblock
*/
defined( 'ABSPATH' ) || exit;
/**
* Register the things.
*/
add_action( 'init', function() {
// automatically load dependencies and version
$asset_file = include( plugin_dir_path( __FILE__ ) . 'build/index.asset.php');
wp_register_script(
'mkaz-test-block-script',
plugins_url( 'build/index.js', __FILE__ ),
$asset_file['dependencies'],
$asset_file['version']
);
wp_register_script(
'mkaz-test-block-client-asset',
plugins_url( 'view.js', __FILE__ )
);
register_block_type( 'mkaz/test-block', array(
'editor_script' => 'mkaz-test-block-script',
'render_callback' => function( $attribs, $content ) {
wp_enqueue_script( 'mkaz-test-block-client-asset' );
return $content;
}
) );
} );