-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathblocksmg.php
More file actions
97 lines (85 loc) · 2.98 KB
/
blocksmg.php
File metadata and controls
97 lines (85 loc) · 2.98 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
<?php
/**
* Plugin Name: Blocksmg
* Description: A plugin of custom blocks by mager19.
* Requires at least: 6.1
* Requires PHP: 7.0
* Version: 0.1.8.3
* Author: Mager19
* Author URI: https://twitter.com/mager19
* License: GPL-2.0-or-later
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
* Text Domain: blocksmg
*
* @category Blocks
* @package CreateBlock
* @author Mager19 <mager19@gmail.com>
* @license GPL-2.0-or-later https://www.gnu.org/licenses/gpl-2.0.html
* @link https://twitter.com/mager19
*/
namespace Blocksmg;
if (! defined('ABSPATH') ) {
die('Silence is golden.');
}
/**
* Constructor Class
*
* @category Blocks
* @package CreateBlock
* @author Mager19 <mager19@gmail.com>
* @license GPL-2.0-or-later https://www.gnu.org/licenses/gpl-2.0.html
* @link https://twitter.com/mager19
*/
require 'plugin-update-checker/plugin-update-checker.php';
use YahnisElsts\PluginUpdateChecker\v5\PucFactory;
final class Blocksmg
{
static function init()
{
add_action(
'init', function () {
add_filter(
'block_categories_all', function ($categories) {
$custom_categories = [
[
'slug' => 'blocksmg',
'title' => __('Blocksmg', 'blocksmg'),
]
];
return array_merge($custom_categories, $categories);
}
);
$blocks = glob(__DIR__ . '/build/blocks/*/block.json');
foreach ($blocks as $block) {
register_block_type($block);
}
$asset_file = include plugin_dir_path(__FILE__) . 'build/index.asset.php';
wp_enqueue_script('index-settings', plugin_dir_url(__FILE__) . '/build/index.js', $asset_file['dependencies'], $asset_file['version'], true);
$global_styles = include plugin_dir_path(__FILE__) . 'build/global-styles.asset.php';
wp_enqueue_style('global-styles', plugin_dir_url(__FILE__) . '/build/global-styles.css', array(), $global_styles['version']);
}
);
$myUpdateChecker = PucFactory::buildUpdateChecker(
'https://github.com/mager19/blocksMg/',
__FILE__,
'Blocksmg'
);
//Set the branch that contains the stable release.
$myUpdateChecker->setBranch('releases');
}
static function paddingBlockClasses($value)
{
$paddingClasses = '';
if ($value) {
foreach ($value as $key => $val) {
if ($key == 'mobilePadding' || $key == 'tabletPadding' || $key == 'desktopPadding') {
$paddingClasses .= 'has-' . $key . '-' . $val . ' ';
}
}
return $paddingClasses;
} else {
return '';
}
}
}
Blocksmg::init();