diff --git a/UltiSnips/javascript.snippets b/UltiSnips/javascript.snippets
index 324a597..3302bfe 100644
--- a/UltiSnips/javascript.snippets
+++ b/UltiSnips/javascript.snippets
@@ -130,8 +130,8 @@ registerBlockType( '${1:namespace}/${2:block-name}', {
icon: '${4:universal-access-alt}',
category: '${5:layout}',
example: {},
- edit() {
- return
Hello World, step 1 (from the editor).
;
+ edit( { className } ) {
+ return Hello World, step 1 (from the editor).
;
},
save() {
return Hello World, step 1 (from the frontend).
;
diff --git a/UltiSnips/php.snippets b/UltiSnips/php.snippets
index 1efa075..a32a09b 100644
--- a/UltiSnips/php.snippets
+++ b/UltiSnips/php.snippets
@@ -5,21 +5,37 @@ public function $1($2) {
endsnippet
snippet wprb "function register_block() { ..."
-function ${1:plugin_name}_register_block() {
+function ${1/-/_/g}_${2/-/_/g}_register_block() {
// automatically load dependencies and version
$asset_file = include( plugin_dir_path( __FILE__ ) . '$2/build/index.asset.php');
wp_register_script(
- '${1/_/-/g}-${2:block-name}',
- plugins_url( '$2/build/index.js', __FILE__ ),
- $asset_file['dependencies'],
- $asset_file['version']
- );
+ '${1:plugin-name}-${2:block-name}',
+ plugins_url( '$2/build/index.js', __FILE__ ),
+ $asset_file['dependencies'],
+ $asset_file['version']
+ );
- register_block_type( '${3:namespace}/${1/_/-/g}-$2',
- array( 'editor_script' => '${1/_/-/g}-$2',) );
+ wp_register_style(
+ '$1-$2-style',
+ plugins_url( '$2/build/style.css', __FILE__ ),
+ array(),
+ filemtime ( plugin_dir_path( __FILE__ ) . '$2/build/style.css' )
+ );
+ wp_register_style(
+ '$1-$2-editor',
+ plugins_url( '$2/build/editor.css', __FILE__ ),
+ array(),
+ filemtime ( plugin_dir_path( __FILE__ ) . '$2/build/editor.css' )
+ );
+
+ register_block_type( 'myguten/$1-$2', array(
+ 'style' => '$1-$2-style',
+ 'editor_style' => '$1-$2-editor',
+ 'editor_script' => '$1-$2',
+ ) );
}
-add_action( 'init', '$1_register_block' );
+add_action( 'init', '${1/-/_/g}_${2/-/_/g}_register_block' );
endsnippet