wp-gutenberg-block-template/svg.php

43 lines
951 B
PHP
Raw Normal View History

2020-08-12 13:20:11 +00:00
<?php
function svg_block_init() {
if ( ! function_exists( 'register_block_type' ) ) {
return;
}
$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/style-index.css';
wp_register_style(
'svg-block-editor',
"$uri/$editor_css",
array(),
filemtime( "$dir/$editor_css" )
);
$style_css = 'build/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' );