| 1 |
<?php |
| 2 |
add_action('wp_enqueue_scripts', 'stm_bookit_frontend_styles'); |
| 3 |
|
| 4 |
function stm_bookit_frontend_styles() { |
| 5 |
$base = STM_BOOKIT_CALENDAR_URL . 'calendar_app/source/dist/static/'; |
| 6 |
$v = (WP_DEBUG) ? time() : '1.0'; |
| 7 |
|
| 8 |
wp_register_style('stm_bookit_calendar_css', $base . 'css/app.css', array(), $v); |
| 9 |
wp_register_script('stm_bookit_calendar_manifest', $base . 'js/manifest.js?v=32432', array(), $v, true); |
| 10 |
wp_register_script('stm_bookit_calendar_vendor', $base . 'js/vendor.js?v=23432', array('stm_bookit_calendar_manifest'), $v, true); |
| 11 |
wp_register_script('stm_bookit_calendar_app', $base . 'js/app.js?v=234342', array('stm_bookit_calendar_vendor'), $v, true); |
| 12 |
} |
| 13 |
|
| 14 |
function stm_bookit_shortcode( $atts ){ |
| 15 |
|
| 16 |
wp_add_inline_script('stm_bookit_calendar_manifest', "var bookit_user_token = '". sanitize_text_field( STM_Bookit_User::get_user_token() ) ."' ", "before"); |
| 17 |
|
| 18 |
wp_add_inline_script('stm_bookit_calendar_manifest', "var bookit_home_url = '". get_home_url() ."' ", "before"); |
| 19 |
|
| 20 |
|
| 21 |
wp_enqueue_style( 'stm_bookit_calendar_css' ); |
| 22 |
wp_enqueue_script( 'stm_bookit_calendar_manifest' ); |
| 23 |
wp_enqueue_script( 'stm_bookit_calendar_manifest' ); |
| 24 |
wp_enqueue_script( 'stm_bookit_calendar_vendor' ); |
| 25 |
wp_enqueue_script( 'stm_bookit_calendar_app' ); |
| 26 |
return "<div id='app'></div>"; |
| 27 |
} |
| 28 |
add_shortcode( 'bookit', 'stm_bookit_shortcode' ); |