-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgrid-blocks.php
66 lines (54 loc) · 1.48 KB
/
grid-blocks.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<?php
/**
* Plugin Name: Grid Blocks
* Description: Gutenberg blocks for creating responsive grid rows, columns, and block grids.
* Version: 6.4.0
* Update URI: false
* Requires at least: 6.4
* Requires PHP: 8.0
* Author: Phil Buchanan
* Author URI: https://philbuchanan.com
* License: GPLv2 or later
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
*/
defined('ABSPATH') || exit;
// Make sure to not redeclare the class
if (!class_exists('PB_Grid_Blocks')) :
class PB_Grid_Blocks {
function __construct() {
add_action('init', array($this, 'register_blocks'));
}
public function register_blocks() {
$asset_file = include(get_template_directory() . '/blocks/build/index.asset.php');
wp_register_script(
'pb-grid-blocks-editor-scripts',
plugins_url('build/index.js', __FILE__),
$asset_file['dependencies'],
$asset_file['version'],
true
);
wp_register_style(
'pb-grid-blocks-editor-styles',
plugins_url('build/index.css', __FILE__),
array('wp-edit-blocks'),
$asset_file['version']
);
$register_blocks = array(
'block-grid/block-grid',
'block-grid/block-grid-item',
'columns/row',
'columns/column',
);
foreach($register_blocks as $json_file) {
register_block_type(
plugin_dir_path(__FILE__) . 'src/' . $json_file . '/block.json',
array(
'editor_script' => 'pb-grid-blocks-editor-scripts',
'editor_style' => 'pb-grid-blocks-editor-styles',
)
);
}
}
}
$PB_Grid_Blocks = new PB_Grid_Blocks;
endif;