-
Notifications
You must be signed in to change notification settings - Fork 29
/
wp-js-plugin-starter.php
50 lines (45 loc) · 1.09 KB
/
wp-js-plugin-starter.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
<?php
/**
* Plugin Name: WP JS Plugin Starter
* Plugin URI: https://github.com/youknowriad/wp-js-plugin-starter
* Description: Just another WordPress plugin starter
* Version: 1.0.1
* Author: Riad Benguella
*
* @package wp-js-plugin-starter
*/
/**
* Retrieves a URL to a file in the plugin's directory.
*
* @param string $path Relative path of the desired file.
*
* @return string Fully qualified URL pointing to the desired file.
*
* @since 1.0.0
*/
function wp_js_plugin_starter_url( $path ) {
return plugins_url( $path, __FILE__ );
}
/**
* Registers the plugin's block.
*
* @since 1.0.0
*/
function wp_js_plugin_starter_register_block() {
if ( ! function_exists( 'register_block_type' ) ) {
return;
}
wp_register_script(
'wp-js-plugin-starter',
wp_js_plugin_starter_url( 'dist/index.js' ),
array( 'wp-blocks', 'wp-element' ),
'1.0.1'
);
register_block_type( 'wp-js-plugin-starter/hello-world', array(
'editor_script' => 'wp-js-plugin-starter',
) );
}
/**
* Trigger the block registration on init.
*/
add_action( 'init', 'wp_js_plugin_starter_register_block' );