-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwz-blocks.php
43 lines (40 loc) · 1.51 KB
/
wz-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
<?php
/**
* Plugin Name: WebberZone Blocks Tester Plugin
* Description: Plugin used to build blocks for WebberZone plugins.
* Requires at least: 5.6
* Requires PHP: 7.1
* Version: 0.6.0
* Author: WebberZone
* License: GPL-2.0-or-later
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
* Text Domain: wz-blocks
*
* @package wz-blocks
*/
/**
* Registers the block using the metadata loaded from the `block.json` file.
* Behind the scenes, it registers also all assets so they can be enqueued
* through the block editor in the corresponding context.
*
* @see https://developer.wordpress.org/block-editor/how-to-guides/block-tutorial/writing-your-first-block-type/
*/
function wz_register_blocks() {
// Register blocks in the format $dir => $render_callback.
$blocks = array(
'related-posts' => 'render_crp_block', // Related Posts.
'popular-posts' => 'render_tptn_block', // Popular Posts.
'popular-authors' => 'render_wzpa_block', // Popular Authors.
'kb' => 'render_wzkb_block', // Knowledge Base.
'followed-posts' => 'render_wfp_block', // Where did they go from here.
'alerts' => '', // Knowledge Base alerts.
);
foreach ( $blocks as $dir => $render_callback ) {
$args = array();
if ( ! empty( $render_callback ) ) {
$args['render_callback'] = $render_callback;
}
register_block_type( plugin_dir_path( __FILE__ ) . 'blocks/' . $dir . '/', $args );
}
}
add_action( 'init', 'wz_register_blocks' );