forked from ubc/ubc-tabs-block
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathubc-tabs-block.php
81 lines (74 loc) · 2.07 KB
/
ubc-tabs-block.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
<?php
/**
* UBC Tab Block
*
* @package SauderBlocks
* @author Christy Yao
* @copyright 2019 Christy Yao
* @license GPL-2.0-or-later
*
* @wordpress-plugin
* Plugin Name: UBC Tab Block
* Plugin URI: https://sauder.ubc.ca/
* Description: Tab Block for UBC Sauder
* Version: 1.0.0
* Author: Christy Yao
* Author URI: https://christyyao.com
* Text Domain: ubc-tab-block
* License: GPL v2 or later
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
*/
add_action('init', 'ubc_tab_blocks_asset_load', 10);
add_action( 'wp_enqueue_scripts', 'ubc_tab_blocks_frontend_assets' );
/**
* Enqueue assets to frontend pages.
*
* @return void
*/
function ubc_tab_blocks_frontend_assets() {
wp_enqueue_script(
'ubc-tab-script-frontend',
plugins_url( 'build/frontend.js', __FILE__ ),
array(),
filemtime( plugin_dir_path( __FILE__ ) . 'build/frontend.js'),
true
);
wp_register_style(
'ubc-tab-style-frontend',
plugins_url( '/build/frontend.css', __FILE__ ),
array('wp-editor'),
filemtime( plugin_dir_path( __FILE__ ) . 'build/frontend.css' )
);
wp_enqueue_style( 'ubc-tab-style-frontend' );
}
/**
* Regiter Tabs block and enqueue block assets.
*
* @return void
*/
function ubc_tab_blocks_asset_load(){
wp_register_script(
'ubc-tab-script-block',
plugins_url( 'build/block.js', __FILE__ ),
array(
'wp-blocks',
'wp-i18n',
'wp-element',
'wp-editor',
'wp-plugins',
'wp-edit-post',
),
filemtime( plugin_dir_path( __FILE__ ) . 'build/block.js'),
true
);
wp_register_style(
'ubc-tab-style-block',
plugins_url( '/build/block.css', __FILE__ ),
array( 'wp-edit-blocks' ),
filemtime( plugin_dir_path( __FILE__ ) . 'build/block.css' )
);
register_block_type( 'ubc/tab', array(
'editor_script' => 'ubc-tab-script-block',
'editor_style' => 'ubc-tab-style-block',
) );
}