-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathunityblocks.php
More file actions
64 lines (58 loc) · 2 KB
/
unityblocks.php
File metadata and controls
64 lines (58 loc) · 2 KB
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
<?php
/**
* Plugin Name: UnityBlocks
* Description: UnityBlocks is a suite of page building content blocks for the ASU Web Standards Unity (UDS) WordPress theme.
* Requires at least: 6.6
* Requires PHP: 7.4
* Version: 4.3.0
* Author: ASU KE Web Services
* Author URI: https://rto.asu.edu/web-services
* License: GPL-2.0-or-later
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
* Text Domain: unityblocks
*
* GitHub Plugin URI: ASU-KE/UnityBlocks
* Primary Branch: main
*
* @package unityblocks
*/
// Exit if accessed directly.
if (!defined('ABSPATH')) {
exit;
}
/**
* Registers the block using the metadata loaded from the `block.json` file.
* Behind the scenes, it also registers all assets so they can be enqueued
* through the block editor in the corresponding context.
*
* @see https://developer.wordpress.org/reference/functions/register_block_type/
*/
function unityblocks_block_init()
{
// check WP version: v6.8+, v6.7, pre 6.7
if ( function_exists( 'wp_register_block_types_from_metadata_collection' ) ) {
wp_register_block_types_from_metadata_collection( __DIR__ . '/build', __DIR__ . '/build/blocks-manifest.php' );
} else {
if ( function_exists( 'wp_register_block_metadata_collection' ) ) {
wp_register_block_metadata_collection( __DIR__ . '/build', __DIR__ . '/build/blocks-manifest.php' );
}
$manifest_data = require __DIR__ . '/build/blocks-manifest.php';
foreach ( array_keys( $manifest_data ) as $block_type ) {
register_block_type( __DIR__ . "/build/{$block_type}" );
}
}
}
add_action('init', 'unityblocks_block_init');
/**
* Register a custom category in the Block Editor that we can use for organizing our blocks.
*/
function unityblocks_register_block_category($categories)
{
// Adding a new category.
$categories[] = array(
'slug' => 'unityblocks',
'title' => 'UnityBlocks'
);
return $categories;
}
add_filter('block_categories_all', 'unityblocks_register_block_category');