-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathainoblocks.php
127 lines (110 loc) · 3.4 KB
/
ainoblocks.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
<?php
/**
* Plugin Name: AinoBlocks - Gutenberg Website Builder Blocks
* Plugin URI: https://ainoblocks.io/
* Description: A collection of website builder blocks for the Gutenberg block editor.
* Requires at least: 5.9
* Tested up to: 6.1
* Requires PHP: 7.0
* Version: 1.13.0
* Author: ElmaStudio
* Author URI: https://elmastudio.de/en/
* License: GPL-2.0-or-later
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
* Text Domain: ainoblocks
*
* @package ainoblocks
*/
/**
* Exit if accessed directly.
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Define most essential constants.
*/
define( 'AINOBLOCKS_VERSION', '1.13.0' );
define( 'AINOBLOCKS_DIR', plugin_dir_path( __FILE__ ) );
define( 'AINOBLOCKS_URL', plugin_dir_url( __FILE__ ) );
/**
* Registers the custom block category
*/
add_filter( 'block_categories_all', function( $categories, $post ) {
return array_merge(
$categories,
array(
array(
'slug' => 'ainoblocks',
'title' => 'AinoBlocks',
),
)
);
}, 10, 2 );
/**
* Registers the blocks
*/
function create_block_ainoblocks_block_init() {
register_block_type( __DIR__ . '/build/testimonial' );
register_block_type( __DIR__ . '/build/sticker' );
register_block_type( __DIR__ . '/build/button' );
register_block_type( __DIR__ . '/build/multiple-buttons' );
register_block_type( __DIR__ . '/build/icon' );
register_block_type( __DIR__ . '/build/hero' );
register_block_type( __DIR__ . '/build/grid-item' );
register_block_type( __DIR__ . '/build/grid-container' );
register_block_type( __DIR__ . '/build/flexbox' );
register_block_type( __DIR__ . '/build/flex-item' );
register_block_type( __DIR__ . '/build/divider' );
register_block_type( __DIR__ . '/build/card' );
register_block_type( __DIR__ . '/build/author' );
register_block_type( __DIR__ . '/build/profile-image' );
register_block_type( __DIR__ . '/build/badge' );
register_block_type( __DIR__ . '/build/accordion-faq' );
}
add_action( 'init', 'create_block_ainoblocks_block_init' );
/**
* Enqueue editor assets
*/
function ainoblocks_editor_assets() {
$filters_path = '/assets/js/filters.js';
$editor_style_path = '/assets/css/editor.css';
// Enqueue the bundled block JS file.
wp_enqueue_script(
'ainoblocks-js',
plugin_dir_url( __FILE__ ) . 'assets/js/filters.js',
[ 'wp-i18n', 'wp-element', 'wp-blocks', 'wp-components', 'wp-editor' ],
filemtime( AINOBLOCKS_DIR . $filters_path ),
true
);
// Enqueue editor only styles.
wp_enqueue_style(
'ainoblocks-editor-style',
plugin_dir_url( __FILE__ ) . 'assets/css/editor.css',
[],
filemtime( AINOBLOCKS_DIR . $editor_style_path )
);
}
add_action( 'enqueue_block_editor_assets', 'ainoblocks_editor_assets' );
/**
* Enqueue frontend CSS
*/
function ainoblocks_frontend_assets() {
$frontend_style_path = '/assets/css/frontend.css';
wp_enqueue_style(
'ainoblocks-frontend-style',
plugin_dir_url( __FILE__ ) . 'assets/css/frontend.css',
null,
filemtime( AINOBLOCKS_DIR . $frontend_style_path )
);
// automatically load dependencies and version
$asset_file = include( plugin_dir_path( __FILE__ ) . 'assets/frontend.asset.php');
wp_enqueue_script(
'-frontend',
plugins_url( 'assets/js/frontend.js', __FILE__ ),
$asset_file['dependencies'],
$asset_file['version'],
true
);
}
add_action( 'enqueue_block_assets', 'ainoblocks_frontend_assets' );