update snippets
This commit is contained in:
parent
112c528ff5
commit
14a25c725c
|
@ -130,8 +130,8 @@ registerBlockType( '${1:namespace}/${2:block-name}', {
|
||||||
icon: '${4:universal-access-alt}',
|
icon: '${4:universal-access-alt}',
|
||||||
category: '${5:layout}',
|
category: '${5:layout}',
|
||||||
example: {},
|
example: {},
|
||||||
edit() {
|
edit( { className } ) {
|
||||||
return <div style={ blockStyle }>Hello World, step 1 (from the editor).</div>;
|
return <div className={ className }>Hello World, step 1 (from the editor).</div>;
|
||||||
},
|
},
|
||||||
save() {
|
save() {
|
||||||
return <div style={ blockStyle }>Hello World, step 1 (from the frontend).</div>;
|
return <div style={ blockStyle }>Hello World, step 1 (from the frontend).</div>;
|
||||||
|
|
|
@ -5,21 +5,37 @@ public function $1($2) {
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
snippet wprb "function register_block() { ..."
|
snippet wprb "function register_block() { ..."
|
||||||
function ${1:plugin_name}_register_block() {
|
function ${1/-/_/g}_${2/-/_/g}_register_block() {
|
||||||
|
|
||||||
// automatically load dependencies and version
|
// automatically load dependencies and version
|
||||||
$asset_file = include( plugin_dir_path( __FILE__ ) . '$2/build/index.asset.php');
|
$asset_file = include( plugin_dir_path( __FILE__ ) . '$2/build/index.asset.php');
|
||||||
|
|
||||||
wp_register_script(
|
wp_register_script(
|
||||||
'${1/_/-/g}-${2:block-name}',
|
'${1:plugin-name}-${2:block-name}',
|
||||||
plugins_url( '$2/build/index.js', __FILE__ ),
|
plugins_url( '$2/build/index.js', __FILE__ ),
|
||||||
$asset_file['dependencies'],
|
$asset_file['dependencies'],
|
||||||
$asset_file['version']
|
$asset_file['version']
|
||||||
);
|
);
|
||||||
|
|
||||||
register_block_type( '${3:namespace}/${1/_/-/g}-$2',
|
wp_register_style(
|
||||||
array( 'editor_script' => '${1/_/-/g}-$2',) );
|
'$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
|
endsnippet
|
||||||
|
|
Loading…
Reference in New Issue