-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
40 lines (37 loc) · 1.12 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
<?php
/**
* Plugin Name: Vue App Dev
* Description: Vuejs app for Bible, Commentaries and more.
*/
function load_vuescripts() {
wp_register_script(
'vue_app',
'http://localhost:5173/src/main.js'
// plugin_dir_url( __FILE__ ) . 'dist/assets/index.6c51e975.js'
);
}
function load_vuestyles() {
wp_enqueue_style(
'vue_css',
plugin_dir_url( __FILE__ ) . 'dist/assets/index.60ed5573.css'
);
}
add_action('wp_enqueue_scripts', 'load_vuescripts');
add_action('wp_enqueue_scripts', 'load_vuestyles');
function add_type_attribute($tag, $handle, $src) {
// if not your script, do nothing and return original $tag
if ( 'vue_app' !== $handle ) {
return $tag;
}
// change the script tag by adding type="module" and return it.
$tag = '<script type="module" src="' . esc_url( $src ) . '"></script>';
return $tag;
}
function handle_shortcode(){
wp_enqueue_script('vue_app');
add_filter('script_loader_tag', 'add_type_attribute' , 10, 3);
return "<div id='app'>"
."Message from Vue: "
."</div>";
}
add_shortcode( 'VueApp', 'handle_shortcode' );