nvim/UltiSnips/php.snippets

42 lines
1.0 KiB
Plaintext
Raw Normal View History

2020-03-19 15:47:31 +00:00
snippet pf "public function ..."
public function $1($2) {
2020-05-10 13:15:31 +00:00
$0
2020-03-19 15:47:31 +00:00
}
endsnippet
2020-05-10 13:15:31 +00:00
2020-05-10 13:18:31 +00:00
snippet wprb "function register_block() { ..."
2020-05-10 21:23:19 +00:00
function ${1/-/_/g}_${2/-/_/g}_register_block() {
2020-05-10 13:15:31 +00:00
// automatically load dependencies and version
$asset_file = include( plugin_dir_path( __FILE__ ) . '$2/build/index.asset.php');
wp_register_script(
2020-05-10 21:23:19 +00:00
'${1:plugin-name}-${2:block-name}',
plugins_url( '$2/build/index.js', __FILE__ ),
$asset_file['dependencies'],
$asset_file['version']
);
2020-05-10 13:15:31 +00:00
2020-05-10 21:23:19 +00:00
wp_register_style(
'$1-$2-style',
plugins_url( '$2/build/style.css', __FILE__ ),
array(),
filemtime ( plugin_dir_path( __FILE__ ) . '$2/build/style.css' )
);
2020-05-10 13:15:31 +00:00
2020-05-10 21:23:19 +00:00
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',
) );
2020-05-10 13:15:31 +00:00
}
2020-05-10 21:23:19 +00:00
add_action( 'init', '${1/-/_/g}_${2/-/_/g}_register_block' );
2020-05-10 13:15:31 +00:00
endsnippet