forked from youknowriad/wp-js-plugin-starter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
wp-js-plugin-starter.php
51 lines (46 loc) · 1.19 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
51
<?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.0
* 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() {
wp_register_script(
'wp-js-plugin-starter',
wp_js_plugin_starter_url( 'dist/index.js' ),
array( 'wp-element', 'wp-editor', 'wp-blocks', 'wp-components' )
);
wp_register_style(
'wp_js_plugin_starter_style',
wp_js_plugin_starter_url( 'dist/index.css' )
);
register_block_type( 'wp-js-plugin-starter/hello-world', array(
'editor_script' => 'wp-js-plugin-starter',
'style' => 'wp_js_plugin_starter_style',
) );
}
/**
* Trigger the block registration on init.
*/
add_action( 'init', 'wp_js_plugin_starter_register_block' );