-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathblockylicious.php
79 lines (69 loc) · 2.21 KB
/
blockylicious.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
67
68
69
70
71
72
73
74
75
76
77
78
79
<?php
/**
* Plugin Name: Blockylicious
* Description: A plugin of funky blocks.
* Requires at least: 6.1
* Requires PHP: 7.0
* Version: 0.1.0
* Author: Saqib Ali
* License: GPL-2.0-or-later
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
* Text Domain: blockylicious
*
* @package create-block
*/
/**
* 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/reference/functions/register_block_type/
*/
namespace Blocky;
if(!defined('ABSPATH')){
die('Silence is golden');
}
final class Blockylicious{
static function init()
{
add_action( 'init', function(){
add_filter('block_categories_all', function($categories){
array_unshift($categories, [
'slug' => 'blockylicious',
'title' => 'Blockylicious'
]);
return $categories;
});
register_block_type( __DIR__ . '/build/blocks/curvy' );
register_block_type( __DIR__ . '/build/blocks/clickyGroup' );
register_block_type( __DIR__ . '/build/blocks/clickyButton' );
register_block_type( __DIR__ . '/build/blocks/piccyGallery' );
register_block_type( __DIR__ . '/build/blocks/piccyImage' );
$script_url = plugins_url('build/index.js', __FILE__);
wp_enqueue_script('blockylicious-index', $script_url, array('wp-blocks', 'wp-element', 'wp-editor'));
$style_url = plugins_url('build/style-index.css', __FILE__);
wp_enqueue_style('blockylicious-style', $style_url, array());
});
add_action('enqueue_block_assets', function(){
$style_url = plugins_url('build/style-index.css', __FILE__);
wp_enqueue_style('blockylicious-style', $style_url, array());
});
}
static function convert_custom_properties($value)
{
$prefix = 'var:';
$prefix_len = strlen($prefix);
$token_in = '|';
$token_out = '--';
if (str_starts_with($value, $prefix)) {
$unwrapped_name = str_replace(
$token_in,
$token_out,
substr($value, $prefix_len)
);
$value = "var(--wp--$unwrapped_name)";
}
return $value;
}
}
Blockylicious::init();