-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.php
89 lines (75 loc) · 2.26 KB
/
index.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
<?php
/**
* Plugin Name: Alpine
* Plugin URI: https://github.com/WordPress/alpine
* Description: A WordPress plugin that demonstrates how to easily add frontend interactivity with Alpinejs.
* Version: 1.1.0
* Author: Lee Shadle
*
* @package alpine
*/
defined( 'ABSPATH' ) || exit;
/**
* Load all translations for our plugin from the MO file.
*/
add_action( 'init', 'alpine_load_textdomain' );
function alpine_load_textdomain() {
load_plugin_textdomain( 'alpine', false, basename( __DIR__ ) . '/languages' );
}
/**
* Registers all block assets so that they can be enqueued through Gutenberg in
* the corresponding context.
*
* Passes translations to JavaScript.
*/
function alpine_register_block() {
// automatically load dependencies and version
$asset_file = include( plugin_dir_path( __FILE__ ) . 'build/index.asset.php');
wp_register_script(
'alpine',
plugins_url( 'build/index.js', __FILE__ ),
$asset_file['dependencies'],
$asset_file['version']
);
wp_register_style(
'alpine-editor',
plugins_url( '/build/index.css', __FILE__ ),
array( 'wp-edit-blocks' ),
filemtime( plugin_dir_path( __FILE__ ) . '/build/index.css' )
);
wp_register_style(
'alpine',
plugins_url( '/build/style-index.css', __FILE__ ),
array(),
filemtime( plugin_dir_path( __FILE__ ) . '/build/style-index.css' )
);
register_block_type(
'alpine/alpine',
array(
'style' => 'alpine',
'editor_style' => 'alpine-editor',
'editor_script' => 'alpine',
)
);
if ( function_exists( 'wp_set_script_translations' ) ) {
/**
* May be extended to wp_set_script_translations( 'my-handle', 'my-domain',
* plugin_dir_path( MY_PLUGIN ) . 'languages' ) ). For details see
* https://make.wordpress.org/core/2018/11/09/new-javascript-i18n-support-in-wordpress/
*/
wp_set_script_translations( 'alpine', 'alpine' );
}
}
add_action( 'init', 'alpine_register_block' );
function alpine_enqueue_frontend_scripts() {
// automatically load dependencies and version
$asset_file = include( plugin_dir_path( __FILE__ ) . 'build/frontend.asset.php');
wp_enqueue_script(
'-frontend',
plugins_url( 'build/frontend.js', __FILE__ ),
$asset_file['dependencies'],
$asset_file['version'],
true
);
}
add_action( 'wp_enqueue_scripts', 'alpine_enqueue_frontend_scripts' );