use constantt for block namespace

This commit is contained in:
Ray Elliott 2020-08-12 20:21:01 +01:00
parent bcd553f4f0
commit 9b67c4deab
2 changed files with 6 additions and 7 deletions

View File

@ -1,10 +1,8 @@
**TODO** - currently the block name is hardcoded to `svg` and theme is `room-vw`.
Need to use templating to create a `<block-name>.php` file (based on `svg.php)`
with the correct theme/block names.
## Usage
Edit `index.php` and `.scss` files, so that the correct block name and
namespace are used.
```sh
npm install

View File

@ -1,7 +1,8 @@
<?php
define( 'BLOCK_NAMESPACE', '<<INSERT BLOCK NAMESPACE HERE>>' )
$block_namespace = BLOCK_NAMESPACE;
$block_slug = basename( dirname( __FILE__ ) );
// TODO calculate this correctly whether this file is within a theme or plugin
$block_namespace = get_option( 'stylesheet' );
add_action( 'init', function() {
global $block_slug, $block_namespace;