forked from nylen/gutenberg-examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gutenberg-boilerplate-es5.php
96 lines (92 loc) · 3.07 KB
/
gutenberg-boilerplate-es5.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
<?php
/**
* Plugin Name: Gutenberg Boilerplate (ES5)
* Plugin URI: https://github.com/WordPress/gutenberg-boilerplate
* Description: This is a plugin demonstrating how to register new blocks for the Gutenberg editor without a Webpack build process.
* Version: 0.1.0
* Author: Gutenberg Team
*
* @package gutenberg-boilerplate
*/
if ( ! defined( 'ABSPATH' ) ) {
die( 'Silence is golden.' );
}
/**
* Registers block scripts and styles for the editing interface.
*
* @since 0.1.0
*/
function gutenberg_boilerplate_es5_enqueue_editor_assets() {
// Block scripts for the editor.
wp_enqueue_script(
'gutenberg-boilerplate-es5-step01',
plugins_url( 'step-01/block.js', __FILE__ ),
array( 'wp-blocks', 'wp-i18n', 'wp-element' ),
filemtime( plugin_dir_path( __FILE__ ) . 'step-01/block.js' )
);
wp_enqueue_script(
'gutenberg-boilerplate-es5-step02',
plugins_url( 'step-02/block.js', __FILE__ ),
array( 'wp-blocks', 'wp-i18n', 'wp-element' ),
filemtime( plugin_dir_path( __FILE__ ) . 'step-02/block.js' )
);
wp_enqueue_script(
'gutenberg-boilerplate-es5-step03',
plugins_url( 'step-03/block.js', __FILE__ ),
array( 'wp-blocks', 'wp-i18n', 'wp-element' ),
filemtime( plugin_dir_path( __FILE__ ) . 'step-03/block.js' )
);
wp_enqueue_script(
'gutenberg-boilerplate-es5-step04',
plugins_url( 'step-04/block.js', __FILE__ ),
array( 'wp-blocks', 'wp-i18n', 'wp-element' ),
filemtime( plugin_dir_path( __FILE__ ) . 'step-04/block.js' )
);
// Block styles for the editor.
wp_enqueue_style(
'gutenberg-boilerplate-es5-step02-editor',
plugins_url( 'step-02/editor.css', __FILE__ ),
array( 'wp-edit-blocks' ),
filemtime( plugin_dir_path( __FILE__ ) . 'step-02/editor.css' )
);
wp_enqueue_style(
'gutenberg-boilerplate-es5-step03-editor',
plugins_url( 'step-03/editor.css', __FILE__ ),
array( 'wp-edit-blocks' ),
filemtime( plugin_dir_path( __FILE__ ) . 'step-03/editor.css' )
);
wp_enqueue_style(
'gutenberg-boilerplate-es5-step04-editor',
plugins_url( 'step-04/editor.css', __FILE__ ),
array( 'wp-edit-blocks' ),
filemtime( plugin_dir_path( __FILE__ ) . 'step-04/editor.css' )
);
}
add_action( 'enqueue_block_editor_assets', 'gutenberg_boilerplate_es5_enqueue_editor_assets' );
/**
* Registers block styles common to the editor and the frontend.
*
* @since 0.1.0
*/
function gutenberg_boilerplate_es5_enqueue_common_assets() {
// Block styles common to the editor and the frontend.
wp_enqueue_style(
'gutenberg-boilerplate-es5-step02',
plugins_url( 'step-02/style.css', __FILE__ ),
array( 'wp-blocks' ),
filemtime( plugin_dir_path( __FILE__ ) . 'step-02/style.css' )
);
wp_enqueue_style(
'gutenberg-boilerplate-es5-step03',
plugins_url( 'step-03/style.css', __FILE__ ),
array( 'wp-blocks' ),
filemtime( plugin_dir_path( __FILE__ ) . 'step-03/style.css' )
);
wp_enqueue_style(
'gutenberg-boilerplate-es5-step04',
plugins_url( 'step-04/style.css', __FILE__ ),
array( 'wp-blocks' ),
filemtime( plugin_dir_path( __FILE__ ) . 'step-04/style.css' )
);
}
add_action( 'enqueue_block_assets', 'gutenberg_boilerplate_es5_enqueue_common_assets' );