44 lines
1.1 KiB
PHP
44 lines
1.1 KiB
PHP
<?php
|
|
function svg_block_init() {
|
|
if ( ! function_exists( 'register_block_type' ) ) {
|
|
return;
|
|
}
|
|
|
|
// remember - for a block defined in a plugin, we will not be using
|
|
// get_template_directory(), etc, it will be the equivalent for plugins.
|
|
$dir = get_template_directory() . '/blocks/svg';
|
|
$uri = get_template_directory_uri() . "/blocks/svg";
|
|
$asset_file = include( get_template_directory() . '/blocks/svg/build/index.asset.php');
|
|
|
|
$index_js = 'build/index.js';
|
|
wp_register_script(
|
|
'svg-block-editor',
|
|
"$uri/$index_js",
|
|
$asset_file['dependencies'],
|
|
$asset_file['version']
|
|
);
|
|
|
|
$editor_css = 'build/index.css';
|
|
wp_register_style(
|
|
'svg-block-editor',
|
|
"$uri/$editor_css",
|
|
array(),
|
|
filemtime( "$dir/$editor_css" )
|
|
);
|
|
|
|
$style_css = 'build/style-index.css';
|
|
wp_register_style(
|
|
'svg-block',
|
|
"$uri/$style_css",
|
|
array(),
|
|
filemtime( "$dir/$style_css" )
|
|
);
|
|
|
|
register_block_type( 'room-vw/svg', array(
|
|
'editor_script' => 'svg-block-editor',
|
|
'editor_style' => 'svg-block-editor',
|
|
'style' => 'svg-block',
|
|
) );
|
|
}
|
|
add_action( 'init', 'svg_block_init' );
|