wp-block-iconify/index.php

55 lines
1.4 KiB
PHP
Raw Normal View History

2020-08-13 12:26:54 +00:00
<?php
define( 'BLOCK_NAMESPACE', 'room-vw' );
$block_namespace = BLOCK_NAMESPACE;
$block_slug = basename( dirname( __FILE__ ) );
add_action( 'init', function() {
global $block_slug, $block_namespace;
if ( ! function_exists( 'register_block_type' ) ) {
return;
}
$dir = get_template_directory() . "/blocks/$block_slug";
$uri = get_template_directory_uri() . "/blocks/$block_slug";
$asset_file = include( get_template_directory() . "/blocks/$block_slug/build/index.asset.php");
$index_js = 'build/index.js';
wp_register_script(
"{$block_slug}-block-editor",
"$uri/$index_js",
$asset_file['dependencies'],
$asset_file['version']
);
$editor_css = 'build/index.css';
wp_register_style(
"{$block_slug}-block-editor",
"$uri/$editor_css",
array(),
filemtime( "$dir/$editor_css" )
);
$style_css = 'build/style-index.css';
wp_register_style(
"{$block_slug}-block",
"$uri/$style_css",
array(),
filemtime( "$dir/$style_css" )
);
register_block_type( "$block_namespace/$block_slug", array(
'editor_script' => "{$block_slug}-block-editor",
'editor_style' => "{$block_slug}-block-editor",
'style' => "{$block_slug}-block",
) );
function room_vw_iconify_enqueue_assets() {
wp_enqueue_script( 'iconify', 'https://code.iconify.design/1/1.0.7/iconify.min.js', array(), '1.0.7', false );
}
add_action( 'enqueue_block_assets', 'room_vw_iconify_enqueue_assets' );
} );