PluginProbe
MyBookTable Bookstore by Stormhill Media / trunk
MyBookTable Bookstore by Stormhill Media vtrunk
3.6.5 trunk
mybooktable / includes / extras / blocks.php

blocks.php in MyBookTable Bookstore by Stormhill Media trunk, at includes/extras/blocks.php

46 lines 1.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
3
4 function mbt_blocks_init() {
5 if(function_exists('register_block_type')) {
6 add_action('init', 'mbt_register_blocks');
7 add_action('enqueue_block_editor_assets', 'mbt_register_block_assets');
8 add_filter('block_categories', 'mbt_add_block_category');
9 }
10 }
11 add_action('mbt_init', 'mbt_blocks_init');
12
13 function mbt_add_block_category($categories) {
14 return array_merge(
15 $categories,
16 array(
17 array(
18 'slug' => 'mybooktable',
19 'title' => __('MyBookTable', 'mybooktable'),
20 'icon' => 'mybooktable',
21 ),
22 )
23 );
24 }
25
26 function mbt_register_blocks() {
27 register_block_type('mybooktable/all-books', array('editor_script' => 'mbt-blocks', 'editor_style' => 'mbt-blocks'));
28 register_block_type('mybooktable/book-series', array('editor_script' => 'mbt-blocks', 'editor_style' => 'mbt-blocks'));
29 register_block_type('mybooktable/book-genre', array('editor_script' => 'mbt-blocks', 'editor_style' => 'mbt-blocks'));
30 register_block_type('mybooktable/book-tag', array('editor_script' => 'mbt-blocks', 'editor_style' => 'mbt-blocks'));
31 register_block_type('mybooktable/book-author', array('editor_script' => 'mbt-blocks', 'editor_style' => 'mbt-blocks'));
32 register_block_type('mybooktable/single-book', array('editor_script' => 'mbt-blocks', 'editor_style' => 'mbt-blocks'));
33 register_block_type('mybooktable/term-list', array('editor_script' => 'mbt-blocks', 'editor_style' => 'mbt-blocks'));
34 }
35
36 function mbt_register_block_assets() {
37 wp_register_script(
38 'mbt-blocks',
39 plugins_url('js/blocks.js', dirname(dirname(__FILE__))),
40 array('wp-api-fetch', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-data', 'wp-element', 'wp-editor', 'wp-i18n', 'wp-url', 'lodash'),
41 MBT_VERSION,
42 true
43 );
44 wp_register_style('mbt-blocks', plugins_url('css/blocks.css', dirname(dirname(__FILE__))), array('wp-edit-blocks'), MBT_VERSION, 'all');
45 }
46